0

I want to know that is there any property or method by which i come to know that a folder is there on the server.

just like if i have this in my web.config:

<appSettings>
     <add key="ImagePath" value="http://server1:801/ImageById/"/>
</appSettings>

and i am getting this key like this:

var URL = System.Configuration.ConfigurationManager.AppSettings["ImagePath"].ToString();

Now i want to know that how to access imageById on the server and save something into this. just like below:

if("Folder exist on this server URL that is ImageById")
{
save images to the folder thorugh code of WCF as the folder has write permission.
}

and i want this functionality in WCF not in ASP.NET.

please help.

Abhishek Mathur
  • 316
  • 1
  • 4
  • 21

2 Answers2

0
    if(Directory.Exists(Server.MapPath("ImabgeById")))
    {
      save images to the folder thorugh code of WCF as the folder has write permission.
    }

also this can be of help How to get working path of a wcf application?

Community
  • 1
  • 1
taher chhabrawala
  • 4,110
  • 4
  • 35
  • 51
  • everything is fine i am getting the values and saving the values but how to give user or client a url path where images are saving so that they can access that – Abhishek Mathur Oct 02 '12 at 10:02
  • i will check it as answer just checking it from my side and then will let u know – Abhishek Mathur Oct 02 '12 at 10:33
  • Hi act i have another problem now i am getting error 'Login failed for user 'NT AUTHORITY\IUSR'.'' that problem is resolved by creating a directory programatically – Abhishek Mathur Oct 02 '12 at 15:31
0

You can use System.IO.Directory.Exists(path) - you simply need to ensure that your WCF service is operating under credentials with adequate permissions to get to the folder in question (otherwise you will encounter an exception).

slugster
  • 49,403
  • 14
  • 95
  • 145
  • in this what should be the path as if i am giving the path same as what i am getting in URL it is giving me exception of URI Format are not allowed – Abhishek Mathur Oct 02 '12 at 09:58
  • @AbhishekMathur You need to convert the URL to a proper file path that is either relative to the location of your WCF service or is absolute. In any case that is a different question, try looking here on SO for previous questions about mapping a URL to a file path - it's been covered lots of times. – slugster Oct 02 '12 at 10:55