Jump to content

  • Log In with Google      Sign In   
  • Create Account


File Replace: Invalid Path Problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Drakken255   Members   -  Reputation: 173

Like
0Likes
Like

Posted 03 August 2012 - 05:33 AM

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?

Sponsor:

#2 rip-off   Moderators   -  Reputation: 7696

Like
0Likes
Like

Posted 03 August 2012 - 05:48 AM

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.


Thus, the filepath argument my patcher gets and in turn the path var should be

Can you log the actual path somewhere?

#3 Drakken255   Members   -  Reputation: 173

Like
0Likes
Like

Posted 03 August 2012 - 06:20 AM

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:\\"

#4 Drakken255   Members   -  Reputation: 173

Like
0Likes
Like

Posted 03 August 2012 - 06:25 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS