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

Path problem

Tim
Hello,

i try to write some data into an XML-file via c#. When I specify the
path like "c:\\temp\\test.xml" the XmlTextWrite could open the file.
But when I tried to get the path from Directory.GetCurrentDirectory()
and combine it with
my file, the XmlTextWriter couldn't open the file.

The returned path from Directory.Get... contains only one \. Is this
the problem?
Does anybody know how to receive the path with two \\? Or is it my
task to scan the string an insert the missing \? I don't think so!

Hope anybody can help.

Thanks!
Tim
Nov 16 '05 #1
4 4199
Can you post some code, where you combine the file name.

--
Regards,

Deepak
[I Code, therefore I am]
"Tim" <ho*******@3-i-d.com> wrote in message
news:62**************************@posting.google.c om...
Hello,

i try to write some data into an XML-file via c#. When I specify the
path like "c:\\temp\\test.xml" the XmlTextWrite could open the file.
But when I tried to get the path from Directory.GetCurrentDirectory()
and combine it with
my file, the XmlTextWriter couldn't open the file.

The returned path from Directory.Get... contains only one \. Is this
the problem?
Does anybody know how to receive the path with two \\? Or is it my
task to scan the string an insert the missing \? I don't think so!

Hope anybody can help.

Thanks!
Tim

Nov 16 '05 #2
All paths use just single backshlash to separate directories. The difference
you see is just in the C# string literal. You can either use:

@"C:\dir1\dir2\dir3"

OR

"C:\\dir1\\dir2\\dir3"

The debugger watch window displays information in one of these formats, the
one it considers better.

And to combine paths, it's best to use Path.Combine(). Or, in the case you
want to get a path relative to current directory, you can use
Path.GetFullPath() as well.

HTH,
Stefan

"Tim" <ho*******@3-i-d.com> wrote in message
news:62**************************@posting.google.c om...
Hello,

i try to write some data into an XML-file via c#. When I specify the
path like "c:\\temp\\test.xml" the XmlTextWrite could open the file.
But when I tried to get the path from Directory.GetCurrentDirectory()
and combine it with
my file, the XmlTextWriter couldn't open the file.

The returned path from Directory.Get... contains only one \. Is this
the problem?
Does anybody know how to receive the path with two \\? Or is it my
task to scan the string an insert the missing \? I don't think so!

Hope anybody can help.

Thanks!
Tim

Nov 16 '05 #3
Hello,

thanks a lot for your help. I've found my error.
I combine the 2 paths via Directory.GetCurrentDirectory() and an
Treeviewnode, DBTree.SelectedNode.FullPath, where my
DBTree.PathSeparator = "\\". The Treeview displays my Database. The
error was, than the db is in another directory called "Parts". Now I add
the "Parts" to the .GetCurrent...() and it works fine ;-)

Today is not my day ...

Thanks again,
Tim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4
Hi,

Nop, it's ok
you have to do something like this

string filename = Directory.GetCurrentDirectory() + "\\" + filename;

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Tim" <ho*******@3-i-d.com> wrote in message
news:62**************************@posting.google.c om...
Hello,

i try to write some data into an XML-file via c#. When I specify the
path like "c:\\temp\\test.xml" the XmlTextWrite could open the file.
But when I tried to get the path from Directory.GetCurrentDirectory()
and combine it with
my file, the XmlTextWriter couldn't open the file.

The returned path from Directory.Get... contains only one \. Is this
the problem?
Does anybody know how to receive the path with two \\? Or is it my
task to scan the string an insert the missing \? I don't think so!

Hope anybody can help.

Thanks!
Tim

Nov 16 '05 #5

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

Similar topics

8
by: Glenn A. Harlan | last post by:
Why am I receiving the below error when calling - Path.GetTempFileName() The directory name is invalid. Description: An unhandled exception occurred during the execution of the current web...
1
by: bob | last post by:
I have created a simple Windows service in VB.Net which installs fine using InstallUtil.exe to install it to, for example "c:\test", or "c:\Windows\YellowBanana", but if I install it to "c:\Program...
5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
12
by: Xah Lee | last post by:
Python Doc Problem Example Quote from: http://docs.python.org/lib/module-os.path.html ---------- split( path) Split the pathname path into a pair, (head, tail) where tail is the last...
13
by: Adam | last post by:
Trying to get an asp.net 2.0 app running and am receiving this error. I see a bunch of people with this error on the net, but no solution: Works fine on my local machine, deployed to a server it...
5
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file"....
10
by: wo_shi_big_stomach | last post by:
Newbie to python writing a script to recurse a directory tree and delete the first line of a file if it contains a given string. I get the same error on a Mac running OS X 10.4.8 and FreeBSD 6.1. ...
34
by: Ben Sizer | last post by:
I've installed several different versions of Python across several different versions of MS Windows, and not a single time was the Python directory or the Scripts subdirectory added to the PATH...
2
by: contractsup | last post by:
Environment: $ uname -a AIX <withheld2 5 000100614C00 $ db2level DB21085I Instance "<withheld>" uses "32" bits and DB2 code release "SQL08024" with level identifier "03050106"....
5
by: =?Utf-8?B?SmVmZiBCZWVt?= | last post by:
Before you respond with "just use GetShortPathName" please read the rest. We have an application that places files on a file server using mapped drives as it's path of choice. The reason for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.