Tuesday, February 28, 2017

C# create folder on runtime



You can try this code: this will read data from app.config for folder path. if the the path is not found then it it will create folder.


 string curDirectory = ConfigurationManager.AppSettings["AppOutPath"];  
 if (Directory.Exists(curDirectory + @"\Uploads"))  
         {  
           // Do something  
         }  
         else  
         {  
           Directory.CreateDirectory(curDirectory + @"\Uploads");  
           // Do something  
         }  



Ensure that this project has Microsoft.Bcl.Build installed and packages.config is located next to the project file

In my Xamarin form application their was dependency Restclient on Microsoft.Bcl.Build Microsoft.Bcl. i just remove all using nuget and ...