[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

writing to a txt file using map path  (console application)

Posted on 2007-10-04
8
Medium Priority
?
2,863 Views
Last Modified: 2012-05-05
Hi experts,

How can i achieve this-----

I was writing to a txt file in my c drive.

Now i need to deploy the app, how can i use mappath to write the file if its saved in my bin folder
  StreamWriter sw = new StreamWriter("C:\\Test.txt", true);

thanks
0
Comment
Question by:SirReadAlot
8 Comments
 

Author Comment

by:SirReadAlot
ID: 20012811
i think something like this


     StreamWriter sw = new StreamWriter(MapPath("C:\\Test.txt", true));
0
 
LVL 11

Expert Comment

by:udhayakumard
ID: 20012829
StreamWriter sw = new StreamWriter(Server.MapPath("~/Test.txt"));
0
 
LVL 11

Expert Comment

by:udhayakumard
ID: 20012832
Else

treamWriter sw = new StreamWriter(Server.MapPath("C:\\Test.txt"));
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:SirReadAlot
ID: 20012839
sorry,

whats the namespace for server
0
 
LVL 7

Expert Comment

by:bungHoc
ID: 20012846
Don't quite understand your question, but here is what I would have done:

string saveTo = "something like a path";
FileStream fileStream = new FileStream(saveTo, FileMode.Create, FileAccess.Write);

Hope this helps.
0
 

Author Comment

by:SirReadAlot
ID: 20012854
hi i am using just this

StreamWriter sw = new StreamWriter(Server.MapPath("~/Test.txt"));

errors saying
The name 'Server' does not exist in the current context      
0
 

Author Comment

by:SirReadAlot
ID: 20012873
I am using a console application
0
 
LVL 14

Accepted Solution

by:
Jai S earned 2000 total points
ID: 20013153
you can use this
StreamWriter sw = new StreamWriter(System.IO.Path.GetFullPath("test.txt"),true);
:-))))
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question