Post build event $(OutDir)

Posted by Rohik under C# on 12/8/2010 | Points: 10 | Views : 6508 | Status : [Member] | Replies : 2
hi all,

I am building windows form application in c#. I have created folder into my application but when i use it I have to write hard coded path.
So I want to copy that folder into out directory. I want to write command if that folder is exist then copy that else make folder(dir)

but I haven't found specified command?
plz help...

Happy Programming!!
Rohi



Responses

Posted by: T.saravanan on: 12/9/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Rohik,

If you create a folder in Current Path means use
string sPath = Environment.CurrentDirectory;


else use system folder means
string sPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);


to using above codes to get a path from system then to create a directory
Refer this link...
http://www.dotnetspider.com/resources/7625-Directory-Create-Check-Delete-Using-C.aspx

Get a files from that Folder...http://www.c-sharpcorner.com/UploadFile/bejoynair/FindFilesinCS12052005042702AM/FindFilesinCS.aspx

Cheers :)

Thanks,
T.Saravanan

Rohik, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: RohiK on: 12/10/2010 [Member] Starter | Points: 25

Up
0
Down
hi T.Saravanan,

thanks for reply. what you suggested is correct but it is not feasible if you want to run application on any PC.

so I want to make directory and copy files from \project\ to that bin\debug\ .
for that you need to run dos command after successful build
we can do this by project-->properties-->build events-->post build events --> write command
I am writing that command but some error like exited with code 1 or 4
my command is
if  not exist "$(TargetDir)DBXml" mkdir  "$(TargetDir)DBXml" copy  /y "$(ProjectDir) DbXml\*.*"  " $(TargetDir)DbXml" ;



where i am going wrong??

Plz help


Happy Programming!!
Rohi

Rohik, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response