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

StreamRead/Write filename issue.

2
in this example:

Expand|Select|Wrap|Line Numbers
  1. using (StreamWriter sw = new StreamWriter("D:\\BrugerID.txt", true))
I want the "BrugerID" to be replaced with a variable. The variable should be a user input.

In my perfect dream world the lines should be like this:

Expand|Select|Wrap|Line Numbers
  1. string fileNameToWrite = Console.ReadLine();
  2. using (StreamWriter sw = new StreamWriter("D:\\{0}.txt",fileNameToWrite, true))
  3. {
  4. //do something.
  5. }
I can't get my head around the logic here, I'm very new to c# - so how do I make this possible?
Jun 9 '12 #1
1 1610
Solemn
2
Expand|Select|Wrap|Line Numbers
  1. string fileName = Console.ReadLine();
  2. using (StreamWriter sw = new StreamWriter("D:\\" + fileName + ".txt", true))
  3.             {
  4.                 sw.WriteLine("LOL");
  5.             }
In my frustration, I answered the question on impulse.
It was awesome and now my problem is solved.
Jun 9 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: S.W. Rasmussen | last post by:
With the risk of being accused of multi-posting I would like to draw the attention to a serious visual basic/windows issue discussed in the microsoft.public.vb.bugs newsgroup. As pointed out below...
12
by: Jens Thiel | last post by:
Hi, is there a reason for C# to require attribute arguments (properties) to be read-write while VB and C++ are happy with only a setter? Simplified Example: public sealed class FooAttribute...
0
by: Bill | last post by:
Hi. I have set a page that reads a file and send it to the browser with the follow commands: ........ Response.ContentType = "Application/x-msdownload"...
9
by: Scott Reynolds | last post by:
Hello! Could someone please provide me a sample, how to extract filename from url? http://www.mydomain.com/eng/Default.aspx -> Default.aspx Thanks Scott
8
by: crjunk | last post by:
I have a field in a SQL Server table named DetailedDescription that is a varchar. If the user adds/edits a detailed description, they do so in a MulltiLine TextBox control. Therefore, they are...
2
by: Woodrow \asim\ Jarvis Hill | last post by:
Hello folks, and Happy Holidays to those celebrating, I'm fairly new to using the .NET framework, and am attempting to do some FTP work. I have to use an authentication connection to a...
12
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
65
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
1
by: btreddy | last post by:
Hii all , when i try to run my aspx page i'm getting the following error. The current identity (BLR0248\ASPNET) does not have write access to...
3
by: unauthorized | last post by:
I'm running a PHP 5.1 on an Apache 2.2 server under Windows XP which I use to develop my web apps. Currently, I am trying to add "upload" functionality to my project, but for some reason, when the...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.