Post build event $(OutDir)

Posted by Rohik under C# on 12/8/2010 | Points: 10 | Views : 7528 | 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!!


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

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...

Get a files from that Folder...

Cheers :)


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

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

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!!

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

Login to post response