[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SaveFileDialog in C# how to..???

Posted on 2006-05-11
5
Medium Priority
?
1,388 Views
Last Modified: 2008-01-09
i'm use wimform by C#.
i have object SaveFileDialog..
when i get:  
               string path;
               this.path = this.SaveFileDialog.ToString();
 output is:
(example): path  = C:\Document\text.txt

but i want only get part:
                 path = text.txt

How to..??hepl me.
0
Comment
Question by:ncsvietnam
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
vb_jonas earned 100 total points
ID: 16664957
after your code:

path = Path.GetFileName(path);

(looks a bit funny but the thing is that Path.GetFileName is the function you can use)

http://msdn2.microsoft.com/en-US/library/system.io.path.getfilename.aspx
0
 
LVL 12

Expert Comment

by:vb_jonas
ID: 16665016
path = system.IO.Path.GetFileName(path);
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 100 total points
ID: 16665050
You can also use the FileInfo() class:

        private void button1_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                System.IO.FileInfo fi = new System.IO.FileInfo(saveFileDialog1.FileName);
                String fileName = fi.Name;
                String folder = fi.DirectoryName;
                String fullPath = fi.FullName;
                MessageBox.Show(fileName + "\n" + folder + "\n" + fullPath);
            }
        }
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 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