How to validating the existence of a remote directory
hi guys, want validate if remote shared path exist.
i know can use : net use \\servername\path validate this.
is there other c# codes can this? (i don't want use webservice in case)
thanks, eric
you can use following code check file exist of not, in case of file not exist return 404 error, file not exist.
webrequest request; webresponse response; string strmsg = string.empty; request = webrequest.create(new uri(networkpath)); request.method = "head"; try { response = request.getresponse(); strmsg = string.format("{0} {1}", response.contentlength, response.contenttype); } catch (exception ex) { //in case of file not exist server return (404) error }
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment