如何指向临时目录 [英] How to Point to Temp Directory
本文介绍了如何指向临时目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
人们.
我正在开发c#Win应用程序,需要指向一些Windows目录,例如已登录用户的temp目录.
我该怎么办?
Hi People.
I''m developing a c# Win Application & need to point to some windows directory like a logged in user''s temp directory.
How could I do this?
Does anyone have any idea, please?
推荐答案
using System;
using System.IO;
namespace TempFolder
{
class Program
{
static void Main(string[] args)
{
// Get temp path
string strTempPath = Path.GetTempPath();
Console.WriteLine("Temp path is {0}", strTempPath);
// Get temp file
string strTempFileName = Path.GetTempFileName();
Console.WriteLine("Temp file name is {0}", strTempFileName);
Console.ReadKey();
}
}
}
将此用于获取临时目录路径
Use this for Get Temporary Directory path
MessageBox.Show(Path.GetTempPath().ToString());
namespace in
System.IO
u中的命名空间可以轻松引用临时变量.例如%temp%"将您重定向到"C:\ Documents&设置\< nt-id> \本地设置\温度'',您可以轻松访问路径!
u can refrence temp variables easily. for ex ''%temp%'' redircts u to ''C:\Documents & Settings\<nt-id>\Local Setting\Temp'' u can acccess tat path esily!
这篇关于如何指向临时目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文