473,667 Members | 2,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File paths in Processes

Hi,

I am trying to use the Process object to launch an application (and in some
cases open a file), however whenever there are any spaces in process FileName
or Arguments I get an error stating the file cannot be found. For example:

Dim p As New Process
Dim pi As New ProcessStartInf o

pi.Arguments = "S:\A Folder\Another Folders\My File.xls"
pi.FileName = "Excel.exe"
p.StartInfo = pi
p.Start()

This code causes a 'file not found' error even when the filepath is correct.
I was wondering if I need to substitute the spaces with a difference
character to get this code to work. Any suggestions would be appreciated.

p.s. The example is for Excel, but I may not necessarily be using that
process.
Nov 21 '05 #1
4 1159
This works ok for me.

Can I suggest you go to the Start / Run prompt and type in excel.exe and see
if it's the path to Excel that is causing the problem?
"Enterprise Andy" <En************ @discussions.mi crosoft.com> wrote in
message news:2D******** *************** ***********@mic rosoft.com...
Hi,

I am trying to use the Process object to launch an application (and in
some
cases open a file), however whenever there are any spaces in process
FileName
or Arguments I get an error stating the file cannot be found. For example:

Dim p As New Process
Dim pi As New ProcessStartInf o

pi.Arguments = "S:\A Folder\Another Folders\My File.xls"
pi.FileName = "Excel.exe"
p.StartInfo = pi
p.Start()

This code causes a 'file not found' error even when the filepath is
correct.
I was wondering if I need to substitute the spaces with a difference
character to get this code to work. Any suggestions would be appreciated.

p.s. The example is for Excel, but I may not necessarily be using that
process.

Nov 21 '05 #2
Nope, my excel seems to be working fine.

Here is an example of the exact path: "s:\Applica tion Data\IBS Reports\Voids
Current Beta.xls". Excel loads up then says "S:\Application .xls" can't be
found, then "data.xls" can't be found, etc. etc.

Nov 21 '05 #3
"Enterprise Andy" <En************ @discussions.mi crosoft.com> schrieb:
I am trying to use the Process object to launch an application (and in
some
cases open a file), however whenever there are any spaces in process
FileName
or Arguments I get an error stating the file cannot be found. For example:

Dim p As New Process
Dim pi As New ProcessStartInf o

pi.Arguments = "S:\A Folder\Another Folders\My File.xls"


Try to put the filename into double quotes:

\\\
pi.Arguments = """S:\A Folder\Another Folders\My File.xls"""
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
Many thanks. the double quotes before and after seem to do the trick.

"Herfried K. Wagner [MVP]" wrote:
"Enterprise Andy" <En************ @discussions.mi crosoft.com> schrieb:
I am trying to use the Process object to launch an application (and in
some
cases open a file), however whenever there are any spaces in process
FileName
or Arguments I get an error stating the file cannot be found. For example:

Dim p As New Process
Dim pi As New ProcessStartInf o

pi.Arguments = "S:\A Folder\Another Folders\My File.xls"


Try to put the filename into double quotes:

\\\
pi.Arguments = """S:\A Folder\Another Folders\My File.xls"""
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1233
by: Kakushi | last post by:
Hi my name is Andrew beginning/intermediate Python User. I am using a win xp computer Python 2.4 I would like to write a python application that would allow me to view paths of all installed files and registry values associated with that file for example I enter the file C:\WINDOWS\iexplorer.exe and it gives me reg value 1, reg value 2, folder 1, folder 2. This will eventually lead into running an application installer, for example...
11
3625
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own rules when it comes to file paths. A lot of Microsoft installers for example, and also installers of other companies, do not work because they handle paths in the following manner:
6
6945
by: ABC | last post by:
I write the code as: <asp:LinkButton ID="LinkButton2" Text='<%# Eval("Title") %>' PostBackUrl='file://<%# Eval("path") %>' runat="server"></asp:LinkButton> But It don't work to download or open file when I clicked. How should I do?
6
2039
by: Ozz | last post by:
Hi there, I have a link on my web page. When clicked, opens up a pdf file that is stored on my server. Every file is specific to a user's user name and I don't want users to see each other's files. For example: When User1 clicks on the link, it opens up http://mydomain.com/files/user1.pdf and when User2 clicks on the link, it opens up http://mydomain.com/files/user2.pdf.
4
2772
by: max | last post by:
Hello, Based on various posts, I've come up with the following code to load data into a js array dynamically without a screen refresh. It works, but you have to push the button twice before it shows the new data that you have changed in the js file. It's almost like something is being cached. Can anyone help? Following is the code from the php and js file: test.php
1
6477
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
16
2396
by: Eran.Yasso | last post by:
Hi, I have a mdb file shared in the LAN. I want to write app that verifies if it's open. If the file is not open, then my app can open the file. if the file is used, then the app won't open it. I also want this app to have handle to this file, then when the user stops editting this file, he can close it using this app.
5
4628
by: Eugene Anthony | last post by:
ds1.Tables.Rows.ItemArray.GetValue(0).ToString() contains the string path: images/5/Video1/qbert.flv if (File.Exists(ds1.Tables.Rows.ItemArray.GetValue(0).ToString())) { //code to execute } Despite the path exist along with the file name, the code never gets executed.
7
6618
by: sudhaMurugesan | last post by:
Hi all, I use asp.net with c#. I upload a file and save in a directory. I want to reopen the file so i check for file exists and then open it. But though the file exists, the file.exists(fullpath) returns false . can anyone help me ? My code is here... string paths = this.MapPath("../TerminateDoc/Excel/" + fileName.Trim()); /* paths = C:\\Inetpub\\wwwroot\\EIS\\Employee.Web\\TerminateDoc\\Excel\\fi0002264ProofDoc20080708101851.txt...
0
8888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8565
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.