Click here to Skip to main content
15,170,078 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hi,

Sorry for my bad English!

I want to by click button run access file in folder.
I use Application.StartupPath for stupfile of project.
This is my code:
1//Process.Start("winaccess.exe", @""+ Application.StartupPath); IS THIS CORRECT?
2           ProcessStartInfo startInfo = new ProcessStartInfo();
3           startInfo.FileName = "Access.exe";
4           startInfo.Arguments =   @""+Application.StartupPath +"\\sama.accdb";
             //after runtime error : "C:\\Users\\UUT\\Documents\\Visual Studio         2010\\Projects\\SAMA\\SAMA\\bin\\Debug\\sama.accdb"--->but this uncorrect!
5           Process.Start(startInfo);



But I face runtime error in the 5th line:

An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll<br />
<br />
Additional information: The system cannot find the file specified
Posted
Comments
Rockstar_ 12-Jul-13 0:07am
   
The Additional information message clearlry states that the file can't find. check the path properly..
Mohammad Sharify 12-Jul-13 0:17am
   
well, you right! i can't how to fix it:
Application.Staruppath get me '\\' instate '\' and this false path
why?
   
No, this is '\', it is only shown as '\\', in C# escaped syntax, that's all.
Look, find your file, nobody will do it for you...
—SA
Sushil Mate 12-Jul-13 1:33am
   
see application.startuppath will give your bin folder's path where your application exe running. where sama.accdb is present?
Mohammad Sharify 12-Jul-13 2:14am
   
tnks for reply.sama.accdb in that folder path (i mean application exe running);
infact i want to create stupfile so i put my database file in this path,is this work correct???
Sushil Mate 12-Jul-13 2:34am
   
but you need to deploy your db.
Mohammad Sharify 12-Jul-13 2:44am
   
actually yes i need to deploy my db,
now, my question is:
i want to create a stupfile and i should attach sama.accdb .

   
Comments
Mohammad Sharify 12-Jul-13 6:58am
   
first tnks for reply,
but i realy dont understand what i do?! R u suggest me some code...
Sushil Mate 12-Jul-13 6:59am
   
please elaborate what exactly you wanted to do? your says something different & you ask something else.
Mohammad Sharify 12-Jul-13 7:15am
   
link u get me is ok , but finally don't understand do witch:
1- use application.startuppath ....
2- normaly connection string like(i mean db path):
-private String connParam = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=

*H:\AB\My Documents\DBControl.accdb;Jet OLEDB:Database Password=password*"
RE

I am very grateful to sustain
Sushil Mate 12-Jul-13 7:17am
   
yes you can do like that but it will not work on different machine as the path will change. use application startup path.
Mohammad Sharify 12-Jul-13 10:07am
   
ok, i use this code:
string path = Application.StartupPath+"\\sama.accdb";
Process.Start("Access.exe", path);
but i face this error:
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll

Additional information: The system cannot find the file specified
-----------------------------------------------------------------------
u can see path of mydb in this link:
http://s1.picofile.com/file/7842795050/samadbpic.jpg
try to use it like:

Dim CurrDir As String = My.Computer.FileSystem.CurrentDirectory

it will store the complete directory path of your application executable file to CurrDir variable.
you can manipulate... :)
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900