File/Directory Exists?
-
This is really an ASP question, but since I'm using C#, I'll post it here. I'm having trouble accessing remote files (or directories) out of my application. I simply want to check if a file exists on the other machine, which is shared on the same network. No dice, always comes up false. I have set up the IUSR_ComputerName and IWAM_ComputerName accounts on the remote computer to match my IIS account. Still returns only false. I've mapped a drive to the network location, and then put that mapped drive into a virtual directory. In the IIS Administrator I can see the files I'm trying to reach through this virtual directory...but the application only returns false. Here's the code from my application:
private void Page_Load(object sender, System.EventArgs e) { if (System.IO.Directory.Exists("Drive")) Response.Write(Server.MapPath("Drive") + " Exists "); else Response.Write(Server.MapPath("Drive") + " does not exist "); }
Thanks for the help on this. If anybody knows another method of accomplishing this same task, I'm all ears. All I can report is that we don't want to run IIS on the remote machine, and we don't particularly want to spawn an application to take care of the file maintenance...we'd like for the code to handle it. :) -
This is really an ASP question, but since I'm using C#, I'll post it here. I'm having trouble accessing remote files (or directories) out of my application. I simply want to check if a file exists on the other machine, which is shared on the same network. No dice, always comes up false. I have set up the IUSR_ComputerName and IWAM_ComputerName accounts on the remote computer to match my IIS account. Still returns only false. I've mapped a drive to the network location, and then put that mapped drive into a virtual directory. In the IIS Administrator I can see the files I'm trying to reach through this virtual directory...but the application only returns false. Here's the code from my application:
private void Page_Load(object sender, System.EventArgs e) { if (System.IO.Directory.Exists("Drive")) Response.Write(Server.MapPath("Drive") + " Exists "); else Response.Write(Server.MapPath("Drive") + " does not exist "); }
Thanks for the help on this. If anybody knows another method of accomplishing this same task, I'm all ears. All I can report is that we don't want to run IIS on the remote machine, and we don't particularly want to spawn an application to take care of the file maintenance...we'd like for the code to handle it. :) -
What is Drive ? in if (System.IO.Directory.Exists("Drive")) Please substitute "Drive" as "x:\\" should work..( where x is mapdrive letter) or if (System.IO.Directory.Exists("\\\\MachineName\\ShareName\\FolderName")) should do Sandeep Naik
-
As Sandeep correctly mentioned, you're looking for the wrong directory. You need to wrap "Drive" in a call to Server.MapPath() as well when calling System.IO.Directory.Exists(), otherwise you're actually searching for a Direcory named "Drive" instead of the mapped one. Regards, mav