Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Well, a strange thing happens to me today.

When I try to step thru my code (debugging with VS 2008) I noticed at the beginning of the file name that there are some invalid characters displayed.

Example : "2030;#myfilename.pdf"

However I don't notice that when the filename is displayed in a document library's column.

Does anyone know why it's like that ? And how to fix it ?

I wondered if it's because I rename it programatically before. Can anyone confirm that ?

thanks a lot for your help.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I could be wrong but I think the 2030 is the item ID, the semicolon being a field separator, and the # indicating the start of the attachment's filename (in the case of a document library, the document's filename).

Which property of SPFile did you see this format in exactly, and in which context (in terms of what were you doing with the code)? I think you might see this format when dealing with the results of a query at XML-level.

share|improve this answer
    
I think I agree with you. Here is the context : I've got a list (displayed in a SharePoint List) of files which is feeded by a caml query resultset. I display in a dedicated column the filename value using this snippet : myItem["Filename"] = myFile.Properties["vti_title"] myItem.SystemUpdate(); The name of the file is badly formatted so I have to rename it using some of its metadata. Do you think that I'd rather use the property myItem.File.Name instead of myFile.Properties["vti_title"] ? thank you –  Anonymous Sep 6 '10 at 19:16
    
Definitely use SPFile.Name rather than accessing the properties - there could be weird XML formatting of special characters such as spaces or foreign characters which could come up in all shapes and sizes if you access the XML format (via Properties), these will all be translated into friendly looking strings with SPFile.Name. –  James Love Sep 6 '10 at 19:21
    
Just as an example, a<space>file.txt could be returned as something like 0;#a__x20__file.txt –  James Love Sep 6 '10 at 19:22
    
thank you very much ! –  Anonymous Sep 6 '10 at 19:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.