Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

c# save a file from an editor in a specific folder and with a specific name without user interaction (winforms)

Posted on 2011-03-18
3
277 Views
Last Modified: 2013-12-17
hi all,

as the title suggests, im trying to save a richtextform as a file in a specific location with a specfic name without user interaction when they click a button

is this possible and can anyone help me out?

Thanks
0
Comment
Question by:awilderbeast
  • 2
3 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35166744
I believe what you are asking is:
System.IO.File.WriteAllText("C:\path\to\output\file.rtf", this.richTextBox1.RTF);

Open in new window

0
 
LVL 1

Author Comment

by:awilderbeast
ID: 35166769
if the folder does not exist will it create it?
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 35167618
No, I don't believe so. You could create it though:
string folder = "C:\\path\\to\\output";
if (!System.IO.Directory.Exists(folder)) System.IO.Directory.CreateDirectory(folder);
System.IO.File.WriteAllText(folder + "\\file.rtf", this.richTextBox1.RTF);

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 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