Sign in to follow this  

File Replace: Invalid Path Problem

This topic is 1961 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I use this line in debug, it works absolutely fine, but not when I build and run the release binary:

[code]
File.Replace(patchCraftDataPath + @"Temp\PatchCraft.ptch", path, patchCraftDataPath + @"Temp\PatchCraft.old");
[/code]

path is equal to "C:\\Users\\<Name>\\Documents\\Visual Studio 2010\\Projects\\PatchCraft\\PatchCraft\\bin\\Debug\\PatchCraft.exe"

When I run the binary, I run it in this folder: "C:\Users\<Name>\Documents\PatchCraft\Publish\PatchCraft"
Thus, the filepath argument my patcher gets and in turn the path var should be: C:\\Users\\<Name>\\Documents\\PatchCraft\\Publish\\PatchCraft\\PatchCraft.exe"

My exception text when I run the binary:
************** Exception Text **************
System.ArgumentException: The path is not of a legal form.
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.File.InternalReplace(String sourceFileName, String destinationFileName, String destinationBackupFileName, Boolean ignoreMetadataErrors)
at System.IO.File.Replace(String sourceFileName, String destinationFileName, String destinationBackupFileName)
at PatchCraft_Patcher.PatchCraftPatcher.PatchDownloadComplete(Object sender, AsyncCompletedEventArgs e)
at System.Net.WebClient.OnDownloadFileCompleted(AsyncCompletedEventArgs e)
at System.Net.WebClient.DownloadFileOperationCompleted(Object arg)

Why is the binary counting the path variable as invalid?

Share this post


Link to post
Share on other sites
From the documentation: http://msdn.microsoft.com/en-us/library/system.io.fileinfo.fileinfo.aspx
[quote]
The file name is empty, contains only white spaces, or contains invalid characters.
[/quote]

[quote]
Thus, the filepath argument my patcher gets and in turn the path var should be
[/quote]
Can you log the actual path somewhere?

Share this post


Link to post
Share on other sites
It turns out that somehow, when it was in Debug, it wrote "C:\" while in binary, it wrote":\" so I'm checking all my filepath cutting again. The path actually comes in starting "file:\\"

Share this post


Link to post
Share on other sites
And That was it! At first it would chop 7 letters off, because I thought "\\" counted as two letters, when it only counts as one. So "file:\\C:\\" turned into ":\\" with 7 chopped, and "C:\\" with 6 chopped. Thanks for the log suggestion.

Share this post


Link to post
Share on other sites

This topic is 1961 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this