Last post Jul 19, 2017 03:21 AM by AngelinaJolie
Jul 18, 2017 07:48 PM|slimbunny|LINK
I need to check to see if my directory exist or not, may you kindly please help.
string path = "//IdeveDB2//msqlserver//FolderTable_One//FolderTable_One//" ;
<-- please provide the correct format for mapping to another server. Thanks.
I am not using server.MapPath since this is accessing folder at a different location....
DirectoryInfo dirInfo = new DirectoryInfo(path)
List<SelectListItem> ListRootFolders = new List<string>() ;
foreach (var dir in dirInfo.GetDirectories())
Jul 18, 2017 07:53 PM|mgebhard|LINK
Also, I believe you are using the wrong slashes for a path.
string path = @"\IdeveDB2\msqlserver\FolderTable_One\FolderTable_One";
Jul 18, 2017 08:00 PM|aj_ankit85|LINK
First, can you access the location from windows 'run'? For example if the location is on the network drive mapped with your computer or server, you should be able to access by putting the path in run like \\<ServerName Or IP>\Folder1\InnderFolder1\
if that's the case then you can check directory's existence by the code
string path = @"\\<ServerName Or IP>\Folder1\InnderFolder1\"
Jul 19, 2017 12:48 AM|oned_gk|LINK
In IIS, maybe you can add new virtual directory called anotherserverfolder in your app, point the virtual directory to the another server folder i.e : \\server2\sharedfolder1
You can get the folder by MapPath("anotherserverfolder")
Another option you can use FTP, then check the folder via FTP
Jul 19, 2017 03:21 AM|AngelinaJolie|LINK
I am not very sure which server you want to connect , but if you could connect it with FTP ,
I found a solution :
One way is: list directories using appropriate System.Net.FtpWebRequest.Method. The method can be System.Net.WebRequestMethods.Ftp.ListDirectory or System.Net.WebRequestMethods.Ftp.ListDirectoryDetail. Read the data in HTTP response System.Net.FtpWebResponse to see which directory exists and which is not.