Thread: GetFiles() Help
View Single Post
  #8 (permalink)  
Old April 17th, 2008, 08:48 AM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

First of all, you're not really replacing the value. Or actually, it looks like you are replacing, but you don't assign the value back:

specificFile.Replace(specificFile.FullName, "CSTLRK")

The return value of the Replace operation is completely ignored.

Also, Replace doesn't replace the file name, it replaces the *underlying* file on disk:

Finally, most of the properties of the FileInfo are read-only so you can't really reassign a new file name.

Instead, create an intermediate object, fill that with the name of the file and add that object to your list that you bind to your grid.

What that intermediate object is depends; ot could be as simple as a string of all you need is the file name. You could also create a simple custom class for this purpose.



Imar Spaanjaars
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.