Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: Write contents of dataset into email Pin
Hum Dum15-Feb-11 20:15
Hum Dum15-Feb-11 20:15 
GeneralRe: Write contents of dataset into email Pin
<<Tash18>>15-Feb-11 20:27
<<Tash18>>15-Feb-11 20:27 
GeneralRe: Write contents of dataset into email Pin
<<Tash18>>15-Feb-11 21:39
<<Tash18>>15-Feb-11 21:39 
GeneralRe: Write contents of dataset into email Pin
Hum Dum15-Feb-11 21:55
Hum Dum15-Feb-11 21:55 
AnswerRe: Write contents of dataset into email Pin
Luc Pattyn16-Feb-11 0:50
sitebuilderLuc Pattyn16-Feb-11 0:50 
AnswerRe: Write contents of dataset into email Pin
PIEBALDconsult16-Feb-11 1:51
mvePIEBALDconsult16-Feb-11 1:51 
Questionget relative path Pin
igalep13215-Feb-11 12:18
igalep13215-Feb-11 12:18 
AnswerRe: get relative path [modified] Pin
Luc Pattyn15-Feb-11 12:38
sitebuilderLuc Pattyn15-Feb-11 12:38 
When file paths aren't absolute (i.e. they don't start at some root point such as C:\), then they are relative to the "current directory" which is some folder, initially most often defaulting to where your EXE is located. If so, @"SomeFolder\fileName" would suffice. However:

1. the initial "current directory" can be different from your EXE's location, e.g. by using an Explorer shortcut with an explicit "current directory" specification.
2. the "current directory" can change at run-time, e.g. if you use a OpenFileDialog, switch folders there, and the code allows this change to persist;
3. it is in general unwise to locate files relative to your EXE's location, as the EXE often gets installed in a location that is (a) shared by multiple users, and (b) not always writable by regular users.

The recommended approach is to give files a specific location, independent of your EXE's location. Microsoft has some guidelines for such folders, and offers some means to get those paths, see Environment.GetFolderPath(). Part of the guidelines is you should create subfolders based on your (or your company's) name, and your product name.
Example:
string folder=Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
folder=Path.Combine(folder, "companyName");
folder=Path.Combine(folder, "productName");
Directory.CreateDirectory(folder);  // no problem if it already exists!
string file=Path.Combine(folder, "document.txt");
File.WriteAllText(file, "this is a file creation demo");
Console.WriteLine("Successfully created file "+file);


Smile | :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

GeneralRe: get relative path Pin
igalep13215-Feb-11 12:42
igalep13215-Feb-11 12:42 
GeneralRe: get relative path Pin
Dave Kreskowiak15-Feb-11 15:21
mveDave Kreskowiak15-Feb-11 15:21 
QuestionLINQ to Entities Pin
Tamimi - Code15-Feb-11 4:52
Tamimi - Code15-Feb-11 4:52 
AnswerRe: LINQ to Entities Pin
Pete O'Hanlon15-Feb-11 5:29
mvePete O'Hanlon15-Feb-11 5:29 
GeneralRe: LINQ to Entities Pin
Tamimi - Code15-Feb-11 5:47
Tamimi - Code15-Feb-11 5:47 
GeneralRe: LINQ to Entities Pin
PIEBALDconsult15-Feb-11 6:31
mvePIEBALDconsult15-Feb-11 6:31 
GeneralRe: LINQ to Entities Pin
Pete O'Hanlon15-Feb-11 6:50
mvePete O'Hanlon15-Feb-11 6:50 
AnswerRe: LINQ to Entities Pin
musefan15-Feb-11 5:54
musefan15-Feb-11 5:54 
GeneralRe: LINQ to Entities Pin
PIEBALDconsult15-Feb-11 6:28
mvePIEBALDconsult15-Feb-11 6:28 
GeneralRe: LINQ to Entities Pin
musefan15-Feb-11 6:50
musefan15-Feb-11 6:50 
GeneralRe: LINQ to Entities Pin
Rob Philpott15-Feb-11 8:29
Rob Philpott15-Feb-11 8:29 
GeneralRe: LINQ to Entities Pin
Not Active15-Feb-11 10:11
mentorNot Active15-Feb-11 10:11 
AnswerRe: LINQ to Entities Pin
PIEBALDconsult15-Feb-11 6:34
mvePIEBALDconsult15-Feb-11 6:34 
AnswerRe: LINQ to Entities Pin
Luc Pattyn15-Feb-11 6:56
sitebuilderLuc Pattyn15-Feb-11 6:56 
GeneralRe: LINQ to Entities Pin
PIEBALDconsult15-Feb-11 7:02
mvePIEBALDconsult15-Feb-11 7:02 
GeneralRe: LINQ to Entities Pin
Pete O'Hanlon15-Feb-11 7:31
mvePete O'Hanlon15-Feb-11 7:31 
AnswerRe: LINQ to Entities Pin
OriginalGriff15-Feb-11 9:48
mveOriginalGriff15-Feb-11 9:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.