Jump to content
  • Advertisement
Sign in to follow this  
Drakken255

File Replace: Invalid Path Problem

This topic is 2174 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:


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


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
Advertisement
From the documentation: http://msdn.microsoft.com/en-us/library/system.io.fileinfo.fileinfo.aspx

The file name is empty, contains only white spaces, or contains invalid characters.
[/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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!