473,396 Members | 1,707 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,396 software developers and data experts.

extra \ charecter in file path


In my c# application
when i use this FileStream fs = File.Open("C:\\Temp\\497_01\\\
\Assumption.txt",FileMode.Open);

1. it works fine, when i ran the exe locally. (e.i : c:\c\temp
\Test.exe)

2. When i execute the exe from share path it throw an exception saying
file does not exists
(e.i :C:\\\TTTYUOT\temp\Test.exe)

Can any one suggest what could be the reason?
thanks
Kumar

May 14 '07 #1
7 3075
On May 14, 2:47 pm, prakashdeh...@gmail.com wrote:
In my c# application
when i use this FileStream fs = File.Open("C:\\Temp\\497_01\\\
\Assumption.txt",FileMode.Open);

1. it works fine, when i ran the exe locally. (e.i : c:\c\temp
\Test.exe)

2. When i execute the exe from share path it throw an exception saying
file does not exists
(e.i :C:\\\TTTYUOT\temp\Test.exe)

Can any one suggest what could be the reason?

thanks
Kumar
Hi,

Can you add more code sample? I still can't get the connection between
the FileStream and the exception.

Moty

May 14 '07 #2
Hi Moty,

The problem is with this line only
File.Open("C:\\Temp\\497_01\\\\Assumption.txt",Fil eMode.Open);

the extra "\\" between present in the file path "497_01\\\
\Assumption".

it runs fine when i execute the code locally but throws exception file
not found when i ran it through network share like :C:\\\TTTYUOT\temp
\Test.exe)
thanks
Kumar
On May 14, 5:51 pm, Moty Michaely <Moty...@gmail.comwrote:
On May 14, 2:47 pm, prakashdeh...@gmail.com wrote:
In my c# application
when i use this FileStream fs = File.Open("C:\\Temp\\497_01\\\
\Assumption.txt",FileMode.Open);
1. it works fine, when i ran the exe locally. (e.i : c:\c\temp
\Test.exe)
2. When i execute the exe from share path it throw an exception saying
file does not exists
(e.i :C:\\\TTTYUOT\temp\Test.exe)
Can any one suggest what could be the reason?
thanks
Kumar

Hi,

Can you add more code sample? I still can't get the connection between
the FileStream and the exception.

Moty

May 14 '07 #3
<pr***********@gmail.comschrieb im Newsbeitrag
news:11*********************@e65g2000hsc.googlegro ups.com...
>
In my c# application
when i use this FileStream fs = File.Open("C:\\Temp\\497_01\\\
\Assumption.txt",FileMode.Open);
First one hint. For file path it's better to use verbatim strings:
.... @"C:\Temp\497_01\\Asumption.txt" ...
this is much easier to read.
>
1. it works fine, when i ran the exe locally. (e.i : c:\c\temp
\Test.exe)
This puzzles me. I couldn't even construct such path.
What Filesystem you are using.
>
2. When i execute the exe from share path it throw an exception saying
file does not exists
(e.i :C:\\\TTTYUOT\temp\Test.exe)
The extra slash seems to have an effect like a relative path.
Where is the file actually located ?
May 14 '07 #4
On May 14, 6:24 pm, "Christof Nordiek" <c...@nospam.dewrote:
<prakashdeh...@gmail.comschrieb im Newsbeitragnews:11*********************@e65g2000hs c.googlegroups.com...
In my c# application
when i use this FileStream fs = File.Open("C:\\Temp\\497_01\\\
\Assumption.txt",FileMode.Open);

First one hint. For file path it's better to use verbatim strings:
... @"C:\Temp\497_01\\Asumption.txt" ...
this is much easier to read.
1. it works fine, when i ran the exe locally. (e.i : c:\c\temp
\Test.exe)

This puzzles me. I couldn't even construct such path.
What Filesystem you are using.
2. When i execute the exe from share path it throw an exception saying
file does not exists
(e.i :C:\\\TTTYUOT\temp\Test.exe)

The extra slash seems to have an effect like a relative path.
Where is the file actually located ?

The file is located at C:\Temp\497_01\Assumption.txt
>>File.Open("C:\\Temp\\497_01\\\\Assumption.txt",F ileMode.Open);
I understand the the path is not correct but it works in local mode
but not in network mode (i.e C:\\\TTTYUOT\temp\Test.exe)

May 14 '07 #5
"Moty Michaely" <Mo*****@gmail.comwrote in message
news:11*********************@l77g2000hsb.googlegro ups.com...
On May 14, 2:47 pm, prakashdeh...@gmail.com wrote:
>In my c# application
when i use this FileStream fs = File.Open("C:\\Temp\\497_01\\\
\Assumption.txt",FileMode.Open);

1. it works fine, when i ran the exe locally. (e.i : c:\c\temp
\Test.exe)

2. When i execute the exe from share path it throw an exception saying
file does not exists
(e.i :C:\\\TTTYUOT\temp\Test.exe)

Can any one suggest what could be the reason?

The .Net permissions are different when you run the executable locally
than when you run it from a share path. The default permissions of a .Net
executabe loaded from a share path do not allow you to perform file IO
operations. You can chage those permissions from the .Net administration
tool in the control panel.
May 14 '07 #6
<pr***********@gmail.comschrieb
The file is located at C:\Temp\497_01\Assumption.txt
>>>File.Open("C:\\Temp\\497_01\\\\Assumption.txt", FileMode.Open);
I understand the the path is not correct but it works in local mode
but not in network mode (i.e C:\\\TTTYUOT\temp\Test.exe)
So, why you don't simply remove the extra slash?

Christof
May 14 '07 #7
On May 14, 6:52 pm, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.orgwrote:
"Moty Michaely" <Moty...@gmail.comwrote in message

news:11*********************@l77g2000hsb.googlegro ups.com...
On May 14, 2:47 pm, prakashdeh...@gmail.com wrote:
In my c# application
when i use this FileStream fs = File.Open("C:\\Temp\\497_01\\\
\Assumption.txt",FileMode.Open);
1. it works fine, when i ran the exe locally. (e.i : c:\c\temp
\Test.exe)
2. When i execute the exe from share path it throw an exception saying
file does not exists
(e.i :C:\\\TTTYUOT\temp\Test.exe)
Can any one suggest what could be the reason?

The .Net permissions are different when you run the executable locally
than when you run it from a share path. The default permissions of a .Net
executabe loaded from a share path do not allow you to perform file IO
operations. You can chage those permissions from the .Net administration
tool in the control panel.

Thanks so much it was a .Net security/permissions issue its is fixed
after adding File IO. to the Zone

May 15 '07 #8

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

Similar topics

2
by: Oleg Ogurok | last post by:
Hi all, On my web page, I have a <OBJECT DATA="mydatafile.ica" ...> which loads Citrix ICA web client. The problem is that I want to generate the mydatafile.ica on the fly (e.g. based on...
8
by: Some Clown | last post by:
Well... after much consultation with folks on this group, I was convinced that using char arrays and such was bad. I had no clue due in no small part to me being a complete newbie, and the fact...
9
by: Durgesh Sharma | last post by:
Hi All, Pleas help me .I am a starter as far as C Language is concerned . How can i Right Trim all the white spaces of a very long (2000 chars) Charecter string ( from the Right Side ) ? or how...
2
by: David Union | last post by:
Hi. I'm posting this here because I don't know exactly what the best group is. This is for an aspx page with Visual Basic as the code-behind page. I am doing very simple code... in the middle...
3
by: QT | last post by:
Dear sirs, I try to put limit for text field to stop charecter entery after 2 charecter. But I have no success. Any idea how can I do? Best Regards
11
by: cdkorzen | last post by:
I'm sorry if this is a rehash, but all I see is the same info. Here's my debacle: I CAN get the PATH_INFO to work. With ANYTHING but ASP. Python, Perl, Cmd files... works fine. ASP can't...
4
by: situ | last post by:
Hello all, i have a column in a table which stores tag lines which are usually less than 500 charecter. when we display the data through the browser some character display as "boxes" or junks....
2
by: ayan4u | last post by:
ok i have two problems... firstly in strict C enviornment is it possible to have a true dynamic charecter array with no predefined length...i mean to say... suppose.. char *array =NULL;...
2
by: mail2ravi123 | last post by:
hi all, plz provide me a function that is used to compare wild char and as well as to compare * charecter and \ charecter in the string FYI if we want to compare a string for * charecter then...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...

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.