Note that there are some explanatory texts on larger screens.

plurals
  1. POillegal character in absolute path
    primarykey
    data
    text
    <p>Okay I know questions similar to this have been asked but none seem to adequately answer my situation. So I have this bit of code:</p> <pre><code>String old = @"C:\emsdropbox\" + readData.Substring(0, readData.IndexOf("renamed")); String newFile = @"C:\emsdropbox\" + readData.Substring(readData.IndexOf("renamed") + 8, readData.Length-(readData.IndexOf("renamed") + 9)); Console.WriteLine(old + " : " + newFile); old = Regex.Replace(old, @"\'", ""); newFile = Regex.Replace(newFile, @"\'", ""); old = old.Trim(); newFile = newFile.Trim(); Console.WriteLine(old + " : " + newFile); System.IO.File.Move(old, newFile);&lt;/code&gt; </code></pre> <p>and from the two writeLines you get:</p> <pre><code> 1. 'C:\emsdropbox\finally2.txt' : 'C:\emsdropbox\finally3.txt' 2. C:\emsdropbox\finally2.txt : C:\emsdropbox\finally3.txt </code></pre> <p>but it continues to give this error:</p> <pre><code>mSystem.ArgumentException: Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path) at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck) at System.IO.Path.GetFullPathInternal(String path) at System.IO.File.Move(String sourceFileName, String destFileName) at TCPListener.getMessage()e this error &lt;/code&gt; </code></pre> <p>I imagine its because of the : but how am I supposed to reference the file without that?</p> <p>this was my next try after someone suggested path.combine:</p> <pre><code>String oldData = readData.Substring(0, readData.IndexOf("renamed")); oldData = Regex.Replace(oldData, @"\'", ""); String newData = readData.Substring(readData.IndexOf("renamed") + 8, readData.Length-(readData.IndexOf("renamed") + 9)); newData = Regex.Replace(newData, @"\'", ""); String old = System.IO.Path.Combine(@"C:\emsdropbox\",oldData); String newFile = System.IO.Path.Combine(@"C:\emsdropbox\", newData); System.IO.File.Move(old, newFile); </code></pre> <p>the result was the same</p> <pre><code>illegal Characters in path at System.IO.Path.CheckInvalidPathChars(String path) at System.IO.Path.Combine(String path1, String path2) at TCPListener.getMessage() </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload