locked
error in CMS project for directory path RRS feed

  • Question

  • User-1298084633 posted

    i made a cms project in C#.


    in web.config

    i wrote <add key="RootDirectory" value="D:\cms\"/></appSettings>
    and in cms.cs i wrote


            string MyDir = ConfigurationSettings.AppSettings["RootDirectory"].Trim();



            DirectoryInfo dirInfo = new DirectoryInfo(MyDir);
            FileInfo[] info = dirInfo.GetFiles();
            DirectoryInfo[] dirs = dirInfo.GetDirectories();

    . my project is running well in my systemor as offline.


    but when i hosted this project on remote server. so its showing error

    Could not find a part of the path



    if you have any solution for the problem so please let me know.




    Saturday, September 10, 2011 7:58 AM

All replies

  • User-2005691517 posted

    Does the remote server have the folder CMS on D drive? Does it even have a D drive?

    Maybe you need to create it.

    Saturday, September 10, 2011 8:00 AM
  • User3866881 posted

    Hello stevedotnet,

    I suggest you creating another Folder (suppose let's call it "Files"), and then put several files there, and then do this please:

    【in app.config】

    <appSettings><add key="RootDirectory" value="Files"/></appSettings>

    【In proj】

    string MyDir = ConfigurationSettings.AppSettings["RootDirectory"].Trim();
    DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath("~/"+MyDir));
    FileInfo[] info = dirInfo.GetFiles();
    DirectoryInfo[] dirs = dirInfo.GetDirectories();


    Sunday, September 11, 2011 8:56 PM
  • User-1298084633 posted

    no, this website is running offline currently, the problem of root directory appears in remote server.

    Wednesday, November 16, 2011 1:52 AM