|
-
Feb 2nd, 2008, 04:01 PM
#1
Thread Starter
Member
[3.0/LINQ] Opening Files?
I never realized this would be such a hassle, and oddly enough, none of my books really helped me out on the matter.
What I did in VB was simply this
Code:
System.Diagnostics.Process.Start("\directory\file.bat")
And it worked.
I've been googling and flipping through pages, but have no idea on how to reproduce this in C#.
Can I please get some help?
Thanks in advance,
Eleven
-
Feb 2nd, 2008, 04:35 PM
#2
Re: [3.0/LINQ] Opening Files?
You'd do it the same way.
Altough, you will have to put an @ in front of the string path (or use double slashes //), or else itll recognize the slashes as escape sequences.
-
Feb 2nd, 2008, 05:21 PM
#3
Thread Starter
Member
Re: [3.0/LINQ] Opening Files?
odd, I tried that and it couldn't find the files.
The program is located in a root folder, and I am looking for a file in a subdirectory down. Here is what it looks like so far:
File is located just before directory, it's here:
Code:
C:\...\File\Directory\File.bat
File.bat is what I'm trying to open. But I get an error saying it cannot find the file specified.
Last edited by Eleven; Feb 2nd, 2008 at 05:25 PM.
-
Feb 2nd, 2008, 05:47 PM
#4
Re: [3.0/LINQ] Opening Files?
oh, sorry for the confusion, what i ment was that you should place the @ infront of the entire string, like this:
System.Diagnostics.Process.Start(@"directory/file.bat")
-
Feb 2nd, 2008, 05:51 PM
#5
Thread Starter
Member
Re: [3.0/LINQ] Opening Files?
Ah okay, my fault then, thanks a lot for your help!
-
Feb 4th, 2008, 03:54 AM
#6
Re: [3.0/LINQ] Opening Files?
To clarify: Strings in C# can contain escape sequences. An example of an escape sequence is \n, which produces a newline character. VB doesn't support these, so backslash characters have no meaning in VB string literals.
To write a backslash in a C# string literal, you can either use the backslash escape sequence \\, or turn it into a verbatim string literal by prepending the @ character, as Atheist showed you. This disables all escape sequences in the literal (except for \", which is necessary for embedding double quote characters).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|