473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 ProcessStartInfo

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 1147
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.microsoft.com> wrote in
message news:2D**********************************@microsof t.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 ProcessStartInfo

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:\Application 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.microsoft.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 ProcessStartInfo

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

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
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...
11
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...
6
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...
6
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...
4
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...
1
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"...
16
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....
5
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 } ...
7
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.