Passing a server path into DirectoryInfo<p align=left><font face=Arial size=2>Hello Everyone,</font></p> <p align=left>I am struck with something related to the server  path. I am trying to give a server path into the DirectoryInfo(), but it is taking the local directory path and saying that the path specified is not found. So can someone help me out in doing this.</p> <p align=left>Thank you in Advance.</p> <p align=left>your dotnetmate.</p>© 2009 Microsoft Corporation. All rights reserved.Thu, 19 Jun 2008 00:15:52 Za2ff6a4f-6183-422c-8f20-522193c59756http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a2ff6a4f-6183-422c-8f20-522193c59756#a2ff6a4f-6183-422c-8f20-522193c59756http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a2ff6a4f-6183-422c-8f20-522193c59756#a2ff6a4f-6183-422c-8f20-522193c59756dotnetmatehttp://social.msdn.microsoft.com/Profile/en-US/?user=dotnetmatePassing a server path into DirectoryInfo<p align=left><font face=Arial size=2>Hello Everyone,</font></p> <p align=left>I am struck with something related to the server  path. I am trying to give a server path into the DirectoryInfo(), but it is taking the local directory path and saying that the path specified is not found. So can someone help me out in doing this.</p> <p align=left>Thank you in Advance.</p> <p align=left>your dotnetmate.</p>Wed, 10 Oct 2007 17:37:31 Z2007-10-10T20:14:23Zhttp://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a2ff6a4f-6183-422c-8f20-522193c59756#cfc7c93d-121c-470b-8ad9-397afdcca00bhttp://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a2ff6a4f-6183-422c-8f20-522193c59756#cfc7c93d-121c-470b-8ad9-397afdcca00bnobugzhttp://social.msdn.microsoft.com/Profile/en-US/?user=nobugzPassing a server path into DirectoryInfo<div class=codeseg><font face="verdana,arial,helvetica,sans-serif" size=2>Be sure to use the UNC name, \\server\share\etc.  Post your code if that's not it.</font></div>Wed, 10 Oct 2007 17:53:02 Z2007-10-10T17:53:02Zhttp://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a2ff6a4f-6183-422c-8f20-522193c59756#c2efe30b-a38c-4a6d-8ef2-42fe40e2730ehttp://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a2ff6a4f-6183-422c-8f20-522193c59756#c2efe30b-a38c-4a6d-8ef2-42fe40e2730edotnetmatehttp://social.msdn.microsoft.com/Profile/en-US/?user=dotnetmatePassing a server path into DirectoryInfo<p>This is my code I want to take the source path from the xml node and give it into the DirectoryInfo which will be copied to destination  in the same way.</p> <p align=left> </p><font color="#0000ff" size=2> <p>foreach</font><font size=2> (</font><font color="#008080" size=2>XmlNode</font><font size=2> node </font><font color="#0000ff" size=2>in</font><font size=2> nodes<img alt=Idea src="http://forums.microsoft.com/MSDN/emoticons/emotion-55.gif">)</p> <p>{</p> <p></font><font color="#008080" size=2>String</font><font size=2> name = node.Name;</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (name == </font><font color="#800000" size=2>&quot;Source&quot;</font><font size=2>)</p> <p>{</p> <p></font><font color="#008080" size=2>DirectoryInfo</font><font size=2> source = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>DirectoryInfo</font><font size=2>(node.InnerText);</p> <p></font><font color="#008080" size=2>String</font><font size=2> sou = node.InnerText.ToString();</p> <p></p> <p>}</p> <p></font><font color="#0000ff" size=2>else</p></font><font size=2> <p>{</p> <p></font><font color="#008080" size=2>String</font><font size=2> des = node.InnerText;</p> <p>}</p> <p></p> <p></font><font color="#008080" size=2>DirectoryInfo</font><font size=2> dir = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>DirectoryInfo</font><font size=2>(</font><font color="#800000" size=2>&quot;Source&quot;</font><font size=2>);</p> <p></font><font color="#008080" size=2>FileInfo</font><font size=2>[] f = dir.GetFiles(</font><font color="#800000" size=2>&quot;*&quot;</font><font size=2>);</p> <p></font><font color="#0000ff" size=2>foreach</font><font size=2> (</font><font color="#008080" size=2>FileInfo</font><font size=2> file </font><font color="#0000ff" size=2>in</font><font size=2> dir.GetFiles(</font><font color="#800000" size=2>&quot;*&quot;</font><font size=2>))</p> <p>{</p> <p></font><font color="#008080" size=2>File</font><font size=2>.Copy(file.FullName,</font><font color="#800000" size=2>&quot;des&quot;</font><font size=2> + file.FullName.Substring(3), </font><font color="#0000ff" size=2>true</font><font size=2>);</p> <p>}</p> <p></font><font color="#008080" size=2>DirectoryInfo</font><font size=2> dir1 = </font><font color="#0000ff" size=2>new</font><font size=2> </font><font color="#008080" size=2>DirectoryInfo</font><font size=2>(</font><font color="#800000" size=2>&quot;\\sou&quot;</font><font size=2>);</p> <p></font><font color="#008080" size=2>DirectoryInfo</font><font size=2>[] dirs = dir1.GetDirectories();</p> <p></font><font color="#0000ff" size=2>foreach</font><font size=2> (</font><font color="#008080" size=2>DirectoryInfo</font><font size=2> d </font><font color="#0000ff" size=2>in</font><font size=2> dirs)</p> <p>{</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (!</font><font color="#008080" size=2>Directory</font><font size=2>.Exists(</font><font color="#800000" size=2>&quot;des&quot;</font><font size=2> + d.Name))</p> <p></font><font color="#008080" size=2>Directory</font><font size=2>.CreateDirectory(</font><font color="#800000" size=2>&quot;des&quot;</font><font size=2> + d.Name);</p> <p>}</p></font> <p align=left><font face=Arial size=2></font> </p>Thanks.Wed, 10 Oct 2007 18:03:16 Z2007-10-10T18:03:16Zhttp://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a2ff6a4f-6183-422c-8f20-522193c59756#9b6de31a-70a7-4629-85b1-1d5205fd3814http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a2ff6a4f-6183-422c-8f20-522193c59756#9b6de31a-70a7-4629-85b1-1d5205fd3814nobugzhttp://social.msdn.microsoft.com/Profile/en-US/?user=nobugzPassing a server path into DirectoryInfo<div class=codeseg><font face="verdana,arial,helvetica,sans-serif" size=2>You are confusing variable names and string constants.  new DirectoryInfo(sou) for one.  Move the &quot;sou&quot; declaration out of the if statement.  An introductory book on C# programming would be highly advisable.</font></div>Wed, 10 Oct 2007 18:16:55 Z2007-10-10T20:14:23Zhttp://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a2ff6a4f-6183-422c-8f20-522193c59756#027214e7-f931-456c-8b57-e70eb91386e3http://social.msdn.microsoft.com/Forums/en/netfxbcl/thread/a2ff6a4f-6183-422c-8f20-522193c59756#027214e7-f931-456c-8b57-e70eb91386e3dotnetmatehttp://social.msdn.microsoft.com/Profile/en-US/?user=dotnetmatePassing a server path into DirectoryInfo<p align=left>Thank you very much, I figured it out the mistake I am  doing, but still trying to solve it.</p>Wed, 10 Oct 2007 19:23:17 Z2007-10-10T20:14:17Z