Microsoft Developer Network > 포럼 홈 > .NET Base Class Library > Passing a server path into DirectoryInfo
질문하기질문하기
 

답변됨Passing a server path into DirectoryInfo

  • 2007년 10월 10일 수요일 오후 5:37dotnetmate 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    Hello Everyone,

    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.

    Thank you in Advance.

    your dotnetmate.

답변

  • 2007년 10월 10일 수요일 오후 6:16nobugzMVP, 중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    You are confusing variable names and string constants.  new DirectoryInfo(sou) for one.  Move the "sou" declaration out of the if statement.  An introductory book on C# programming would be highly advisable.
  • 2007년 10월 10일 수요일 오후 7:23dotnetmate 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    Thank you very much, I figured it out the mistake I am  doing, but still trying to solve it.

모든 응답

  • 2007년 10월 10일 수요일 오후 5:53nobugzMVP, 중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Be sure to use the UNC name, \\server\share\etc.  Post your code if that's not it.
  • 2007년 10월 10일 수요일 오후 6:03dotnetmate 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    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.

     

    foreach (XmlNode node in nodesIdea)

    {

    String name = node.Name;

    if (name == "Source")

    {

    DirectoryInfo source = new DirectoryInfo(node.InnerText);

    String sou = node.InnerText.ToString();

    }

    else

    {

    String des = node.InnerText;

    }

    DirectoryInfo dir = new DirectoryInfo("Source");

    FileInfo[] f = dir.GetFiles("*");

    foreach (FileInfo file in dir.GetFiles("*"))

    {

    File.Copy(file.FullName,"des" + file.FullName.Substring(3), true);

    }

    DirectoryInfo dir1 = new DirectoryInfo("\\sou");

    DirectoryInfo[] dirs = dir1.GetDirectories();

    foreach (DirectoryInfo d in dirs)

    {

    if (!Directory.Exists("des" + d.Name))

    Directory.CreateDirectory("des" + d.Name);

    }

     

    Thanks.
  • 2007년 10월 10일 수요일 오후 6:16nobugzMVP, 중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    You are confusing variable names and string constants.  new DirectoryInfo(sou) for one.  Move the "sou" declaration out of the if statement.  An introductory book on C# programming would be highly advisable.
  • 2007년 10월 10일 수요일 오후 7:23dotnetmate 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    Thank you very much, I figured it out the mistake I am  doing, but still trying to solve it.