Cannot access project text files in VS2005

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Consider a WindowsApplication in VS2005 named "MyApp". In addition to the
default "Resource" folder you create a new project folder named "NewFolder"
and add a text file in this folder named "TextFile1.txt" and a C# class named
"Class1.cs".
The project hierarchy would then look like this in the Solution Explorer:

======================
Solution 'MyApp'
-MyApp
...
+Resources
NewFolder
Class1.cs
TextFile1.txt
===============

The "Class1.cs" file (included in the project namespace) can be accessed by
typing 'MyApp.NewFolder.Class1', but how can the text file be accessed
without explicitly writing the entire file path?

For instanse, say you want to read the text in "TextFile1.txt" using the
File.ReadAllText() method. How can the file path passed to the ReadAllText()
method be expressed as a pointer to the text file included in the project ?
(writing File.ReadAllText("C:\\....") is not an option since this of course
will stop working once the project is moved).
 
Sounds like you need a my documents open dialog box and let the user find the
textfile1.text

Good Luck
DWS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top