本文整理汇总了C#中System.IO.FileInfo.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.ToString方法的具体用法?C# FileInfo.ToString怎么用?C# FileInfo.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFilePath
public static string GetFilePath(this OleMenuCommand command)
{
string filePath = String.Empty;
command.Visible = false;
command.Enabled = false;
uint itemid = VSConstants.VSITEMID_NIL;
IVsHierarchy hierarchy = null;
if (!command.IsSingleProjectItemSelection(out hierarchy, out itemid)) return null;
// Get the file path
string itemFullPath = null;
((IVsProject)hierarchy).GetMkDocument(itemid, out itemFullPath);
var transformFileInfo = new FileInfo(itemFullPath);
string ext = Path.GetExtension(transformFileInfo.ToString().ToLower());
bool isProperExtension = false;
if (Globals.FileTypes.ContainsKey(ext))
{
isProperExtension = true;
}
filePath = transformFileInfo.ToString();
// if not leave the menu hidden
if (!isProperExtension) return null;
return filePath;
}
示例2: PrepareFakeWebInput
internal static HttpPostedFileBase PrepareFakeWebInput(FileInfo file)
{
var fakeWebInput = A.Fake<HttpPostedFileBase>();
var stream = File.Open(file.ToString(), FileMode.Open);
A.CallTo(() => fakeWebInput.InputStream).Returns(stream);
A.CallTo(() => fakeWebInput.FileName).Returns(file.ToString());
return fakeWebInput;
}
示例3: CombatHudReadWriteSettings
private void CombatHudReadWriteSettings(bool read)
{
try
{
FileInfo GearTacticianSettingsFile = new FileInfo(GearDir + @"\GearTactician.xml");
if (read)
{
try
{
if (!GearTacticianSettingsFile.Exists)
{
try
{
using (XmlWriter writer = XmlWriter.Create(GearTacticianSettingsFile.ToString()))
{
XmlSerializer serializer2 = new XmlSerializer(typeof(GearTacticianSettings));
serializer2.Serialize(writer, gtSettings);
writer.Close();
}
}
catch (Exception ex) { LogError(ex); }
}
using (XmlReader reader = XmlReader.Create(GearTacticianSettingsFile.ToString()))
{
XmlSerializer serializer = new XmlSerializer(typeof(GearTacticianSettings));
gtSettings = (GearTacticianSettings)serializer.Deserialize(reader);
reader.Close();
}
}
catch
{
gtSettings = new GearTacticianSettings();
}
}
if(!read)
{
if(GearTacticianSettingsFile.Exists)
{
GearTacticianSettingsFile.Delete();
}
using (XmlWriter writer = XmlWriter.Create(GearTacticianSettingsFile.ToString()))
{
XmlSerializer serializer2 = new XmlSerializer(typeof(GearTacticianSettings));
serializer2.Serialize(writer, gtSettings);
writer.Close();
}
}
}catch(Exception ex){LogError(ex);}
}
示例4: GearInspectorReadWriteSettings
private void GearInspectorReadWriteSettings(bool read)
{
try
{
FileInfo GearInspectorSettingsFile = new FileInfo(GearDir + @"\GearInspector.xml");
if (read)
{
try
{
if (!GearInspectorSettingsFile.Exists)
{
try
{
string filedefaults = GetResourceTextFile("GearInspector.xml");
using (StreamWriter writedefaults = new StreamWriter(GearInspectorSettingsFile.ToString(), true))
{
writedefaults.Write(filedefaults);
writedefaults.Close();
}
}
catch (Exception ex) { LogError(ex); }
}
using (XmlReader reader = XmlReader.Create(GearInspectorSettingsFile.ToString()))
{
XmlSerializer serializer = new XmlSerializer(typeof(GearInspectorSettings));
GISettings = (GearInspectorSettings)serializer.Deserialize(reader);
reader.Close();
}
}
catch
{
GISettings = new GearInspectorSettings();
}
}
if(!read)
{
if(GearInspectorSettingsFile.Exists)
{
GearInspectorSettingsFile.Delete();
}
using (XmlWriter writer = XmlWriter.Create(GearInspectorSettingsFile.ToString()))
{
XmlSerializer serializer2 = new XmlSerializer(typeof(GearInspectorSettings));
serializer2.Serialize(writer, GISettings);
writer.Close();
}
}
}catch(Exception ex){LogError(ex);}
}
示例5: addLastTime
void addLastTime(FileInfo file)
{
if (!file.Exists) return;
lock (m_syncOjbect)
{
if (wordsLastTime.ContainsKey(file.ToString()))
{
wordsLastTime[file.ToString()] = file.LastWriteTime.ToFileTime();
}
else
{
wordsLastTime.Add(file.ToString(), file.LastWriteTime.ToFileTime());
}
}
}
示例6: setUp
public override void setUp()
{
base.setUp();
_home = new DirectoryInfo(Path.Combine(trash.ToString(), "home"));
_configFile = new FileInfo(Path.Combine(_home.ToString(), ".ssh"));
Directory.CreateDirectory(_configFile.ToString());
_configFile = new FileInfo(Path.Combine(_configFile.ToString(), "config"));
// can't do
//Environment.UserName = "jex_junit";
_osc = new OpenSshConfig(_home, _configFile);
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
string sPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath);
if(oInfo.ToString() == "/history/Default.aspx") LiteralAudio.Text = "so.addVariable('audioPlay', 'false');" ;
}
示例8: TestToString
public void TestToString()
{
var a = new ZlpFileInfo(@"C:\ablage\test.txt");
var b = new FileInfo(@"C:\ablage\test.txt");
var x = a.ToString();
var y = b.ToString();
Assert.AreEqual(x,y);
// --
a = new ZlpFileInfo(@"C:\ablage\");
b = new FileInfo(@"C:\ablage\");
x = a.ToString();
y = b.ToString();
Assert.AreEqual(x,y);
// --
a = new ZlpFileInfo(@"test.txt");
b = new FileInfo(@"test.txt");
x = a.ToString();
y = b.ToString();
Assert.AreEqual(x,y);
// --
a = new ZlpFileInfo(@"c:\ablage\..\ablage\test.txt");
b = new FileInfo(@"c:\ablage\..\ablage\test.txt");
x = a.ToString();
y = b.ToString();
Assert.AreEqual(x,y);
// --
a = new ZlpFileInfo(@"\ablage\test.txt");
b = new FileInfo(@"\ablage\test.txt");
x = a.ToString();
y = b.ToString();
Assert.AreEqual(x,y);
// --
a = new ZlpFileInfo(@"ablage\test.txt");
b = new FileInfo(@"ablage\test.txt");
x = a.ToString();
y = b.ToString();
Assert.AreEqual(x,y);
}
示例9: TemplateException
/// <summary>
/// Retrieves a template from the system, compiling it if needed.
/// </summary>
public ITemplate this[FileInfo file]
{
get
{
// Check the hash
ITemplate template = (ITemplate) templates[file.FullName];
if (template != null)
return template;
// Ignore blanks
if (!file.Exists)
{
throw new TemplateException("File does not exist: "
+ file);
}
// Create the template
Debug("Parsing template: " + file);
TextReader reader = file.OpenText();
template = factory.Create(reader, file.ToString());
reader.Close();
// Save the template and return it
templates[file.FullName] = template;
return template;
}
}
示例10: SetRandomWallpaperFromPath
public static void SetRandomWallpaperFromPath(FileInfo file, Style style)
{
if (file == null) return;
SystemParametersInfo(SetDesktopWallpaper, 0, file.ToString(), UpdateIniFile | SendWinIniChange);
var key = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);
if (key == null) return;
switch (style)
{
case Style.Stretch:
key.SetValue(@"WallpaperStyle", "2");
key.SetValue(@"TileWallpaper", "0");
break;
case Style.Center:
key.SetValue(@"WallpaperStyle", "1");
key.SetValue(@"TileWallpaper", "0");
break;
case Style.Tile:
key.SetValue(@"WallpaperStyle", "1");
key.SetValue(@"TileWallpaper", "1");
break;
case Style.NoChange:
break;
}
key.Close();
}
示例11: SaveSettings
public void SaveSettings()
{
DirectoryInfo SettingsFolder = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\Decal Plugins\Gleaner\Settings");
FileInfo SettingsFile = new FileInfo(SettingsFolder.FullName + @"\Settings.xml");
FileInfo KeyFile = new FileInfo(SettingsFolder.FullName + @"\Keys.xml");
using(XmlWriter writer = XmlWriter.Create(SettingsFile.ToString()))
{
bool[] operationflags = new bool[2];
gleaneron = operationflags[0] = gleaneron;
operationflags[1] = gleanerreport;
XmlSerializer serializer = new XmlSerializer(typeof(bool[]));
serializer.Serialize(writer, operationflags);
writer.Close();
}
using (XmlWriter writer2 = XmlWriter.Create(KeyFile.ToString()))
{
XmlSerializer serializer2 = new XmlSerializer(typeof(KeyClass));
serializer2.Serialize(writer2, MasterKeyClass);
writer2.Close();
}
CoreManager.Current.Actions.AddChatText(("Settings Saved."), 9, 5);
}
示例12: GetData
public List<List<Double>> GetData(FileInfo infile)
{
StreamReader sr = new StreamReader(infile.ToString());
string Line = null;
string subline;
List<List<double>> Table = new List<List<double>>();
if (!infile.Exists)
Console.WriteLine(@"Can't find Files! ");
Line = sr.ReadLine();
while ((Line = sr.ReadLine()) != null){
Line = Line + ",";
List<double> sample = new List<double>();
while (Line.Contains(",")){
subline = Line.Substring(0, Line.IndexOf(","));
sample.Add(Double.Parse(subline));
Line = Line.Substring(Line.IndexOf(",") + 1, Line.Length - Line.IndexOf(",") - 1);
}//one line finish
Table.Add(sample);
}
//Transaction of Attributes
/* for (int i = 1; i < Table[0].Count();i++){
List<double> sampleT = new List<double>();
for (int j = 0; j < Table.Count(); j++) {
sampleT.Add(Table[j][i]);
}
Attributes.Add(sampleT);
}*/
return Table;
}
示例13: InitializeRole
private void InitializeRole(FileInfo file)
{
XmlDocument xml = new XmlDocument();
xml.Load(file.ToString());
XmlElement root=xml.DocumentElement;
List<Operate> operates = new List<Operate>();
Dictionary<int, string> operatesDic = new Dictionary<int, string>();
foreach(XmlNode node in root.GetElementsByTagName("operates")){
foreach (XmlNode n in node.SelectNodes("operate")) {
Operate operate = new Operate();
operate.Name = n.Attributes["name"].Value.ToString();
operate.Value = Convert.ToInt32(n.Attributes["value"].Value.ToString());
operates.Add(operate);
operatesDic.Add(Convert.ToInt32(n.Attributes["value"].Value.ToString()), n.Attributes["url"].Value.ToString());
}
}
this.Operates = operates;
List<Menu> menus = new List<Menu>();
foreach (XmlNode node in root.GetElementsByTagName("menus")) {
foreach (XmlNode menuNode in node.SelectNodes("menu")) {
Menu menu = new Menu();
List<SubMenu> subMenus = new List<SubMenu>();
foreach (XmlNode subNode in menuNode.SelectNodes("submenu"))
{
SubMenu subMenu = new SubMenu();
List<Item> items = new List<Item>();
Dictionary<int, string> Urls = new Dictionary<int, string>();
subMenu.Name = subNode.Attributes["name"].Value.ToString();
subMenu.Value = Convert.ToInt32(subNode.Attributes["value"].Value.ToString());
foreach (XmlNode nodeItem in subNode.SelectNodes("item"))
{
Item item = new Item();
item.Name = nodeItem.Attributes["name"].Value.ToString();
item.Value = Convert.ToInt32(nodeItem.Attributes["value"].Value);
item.Operates = nodeItem.Attributes["operates"].Value.ToString();
item.Url = nodeItem.Attributes["url"].Value.ToString();
items.Add(item);
if (item.Operates != null) {
string[] operateArray = (nodeItem.Attributes["operates"].Value.ToString()).Split(',');
foreach (string operateStr in operateArray) {
// if(Convert.toi)
}
}
Urls.Add(Convert.ToInt32(nodeItem.Attributes["value"].Value), nodeItem.Attributes["url"].Value.ToString());
}
menu.Name = menuNode.Attributes["name"].Value.ToString();
menu.Value = Convert.ToInt32(menuNode.Attributes["value"].Value);
subMenu.Items = items;
subMenus.Add(subMenu);
menu.SubMenus = subMenus;
}
menus.Add(menu);
}
this.Menus = menus;
}
this.InitializeMessage = "文件初始化完毕!";
this.InitializeSuccess = true;
}
示例14: CheckDirInfo
static void CheckDirInfo(string[] args)
{
fDirInfo = new FileInfo(args[0]);
try
{
Sortdir = args[1];
}
catch (Exception)
{
Sortdir = @"C:\Sort\";
}
Console.WriteLine("Папка с отсортированными файлами = {0} \n(Нажмите любую кнопку для начала сортировки)", Sortdir);
Console.ReadKey();
DirInfo = GetDirInfo();
string diend = String.Format("{0}{1}", DirInfo.FullName, "\u005c");
if (fDirInfo.ToString().CompareTo(diend) != 0)
{
Console.WriteLine(@"А гдэ '\' в конце?");
Console.Write(@"Выбранная директория: {0} [ Y/N/'Any key' ] ( 'N' перейти в = {1}\ 'Any key' - Выход ) ",
DirInfo.FullName, fDirInfo.ToString());
string yn = Console.ReadLine();
switch (yn)
{
case "y":
case "Y":
break;
case "n":
case "N":
diend = null;
args[0] = String.Format("{0}{1}", fDirInfo.ToString(), "\u005c");
CheckDirInfo(SetArgs);
break;
default:
Exit();
break;
}
}
}
示例15: Serialize
/// <summary>
/// Serializes the current instance of the Author class.
/// </summary>
public void Serialize()
{
string fileName = string.Format(@"C:\Users\Viktor\Desktop\GitHub\HackBulgaria-CSharp\Week 8\TEST\" + this.Name + " Serialized.txt");
FileInfo file = new FileInfo(fileName);
using (FileStream s = new FileStream(file.ToString(), FileMode.Create, FileAccess.ReadWrite))
{
BinaryFormatter b = new BinaryFormatter();
b.Serialize(s, this);
}
}