Thread: GetFiles() Help
View Single Post
  #7 (permalink)  
Old April 16th, 2008, 10:43 PM
adamcherochak adamcherochak is offline
Authorized User
 
Join Date: Sep 2007
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Again,

I am using the code posted above, it works perfectly (thank you Imar!). I am now attempting to change the file name just before it is collected in the "filteredList" array. I'm thinking I might need to convert from stream to string for this to work??...

The included code shows my feeble attempt change the file name. I would prefer to prefix the file name based on the first character of the file name.

Ideally my DataGrid row would display a custom custom file name like this:
Original File Name= 1myFile.txt
Modified File Name= CSTLRKmyFile.txt

Code:
For Each specificFile In fileArray
     If specificFile.Extension = ".txt" Or specificFile.Extension = ".doc" Then
          If specificFile.Name.StartsWith("1") Then
               specificFile.Replace(specificFile.FullName, "CSTLRK")
               'collect files with desired extensions and new name
               filteredList.Add(specificFile)
          End If
     End If
Next specificFile
dgArticleList.DataSource = filteredList
dgArticleList.DataBind()