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
274 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 74

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 74

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now