Question

I am writing a utility that edits .docx files. I've made it so that when the user right clicks on the correct type of file, it automatically makes the changes and saves the document with a bit of text appended to the file name. All of this works great, except for the fact that I am receiving heavily truncated file names. If the file name contains more than one word, the string passed to the program is has most of its characters replaced by a single ~. Is there any way to either read the original file name, or have the parameter be the full string?

Was it helpful?

Solution

I found the solution to what I was trying to do. I ended up using the C# method Path.GetFullPath.

string path = Path.GetFullPath(originalpath);

This outputs the full file name as opposed to the truncated one.

http://msdn.microsoft.com/en-us/library/system.io.path.getfullpath.aspx

OTHER TIPS

File.getCanonicalPath will give you what you want

http://msdn.microsoft.com/en-us/library/aa988183(v=vs.80).aspx

Put the whole path between two double quot; like:

var fn = "\"C:\\Path With Spaces And Special Characters\\#\\to\\My File.docx\"";
// send fn as an argument to the other process
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top