티스토리 뷰
현재 실행 중인 어플리케이션과 같은 폴더에 있는 파일이나, 하위 폴더에 있는 파일의 위치를 지정하고자 한다면, Path 클래스를 사용하면 된다.
아래는 간단한 예제이다.
Application.ExecutablePath 은 현재 실행 중인 어플리케이션의 위치를 반환한다.
Path.GetDirectoryName 은 path에서 폴더 값만 반환한다.
Path.Combine 은 두개의 path를 결합한다.
using System;
using System.IO;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "file.txt");
}
}
}
아래는 간단한 예제이다.
Application.ExecutablePath 은 현재 실행 중인 어플리케이션의 위치를 반환한다.
Path.GetDirectoryName 은 path에서 폴더 값만 반환한다.
Path.Combine 은 두개의 path를 결합한다.
using System;
using System.IO;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "file.txt");
}
}
}
'Code > C#' 카테고리의 다른 글
| List<string> 객체의 XML Serialization 사용 예제 (0) | 2007.12.15 |
|---|---|
| XML Serialization 사용법과 예제 (0) | 2007.12.15 |
| Windows Form Application의 Path를 구하는 방법 (0) | 2007.12.15 |
| 실행중인 application의 path를 구하는 방법 (0) | 2007.12.15 |
| BinaryFormatter.Serialize 사용법 (0) | 2007.12.12 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Service pack
- java
- windows
- DotNetMagic
- READYSTATE_COMPLETE
- registry
- Rollback Rx
- Automation
- Regular Expressions
- AxWebBrowser
- download.com
- 애드센스감추기
- tagREADYSTATE
- AdSense숨기기
- jre
- .net framework
- Microsoft
- 유틸리티
- ScreenHunter
- iText
- WinAutomation
- AdSense감추기
- Phalanger
- 애드센스숨기기
- Sample Code
- autohotkey
- c#
- iTextSharp
- 스크린캡쳐
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
글 보관함