本文整理汇总了C#中System.IO.FileInfo.CreateDirectory_IfNotExists方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.CreateDirectory_IfNotExists方法的具体用法?C# FileInfo.CreateDirectory_IfNotExists怎么用?C# FileInfo.CreateDirectory_IfNotExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileInfo
的用法示例。
在下文中一共展示了FileInfo.CreateDirectory_IfNotExists方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadWeatherData
private bool LoadWeatherData(String weatherFileName)
{
DateTime actuallTime = DateTime.Now;
FileInfo weatherFileInfo = new FileInfo(weatherFileName);
if ((weatherFileInfo.Exists)
&& (weatherFileInfo.LastWriteTime.AddMinutes(58) > actuallTime))
return false;
String rawDataName = "http://aps.mowis.at/kunden/wpmedia/getForecasts.php";
XmlDocument weatherData = new XmlDocument();
try
{
weatherData.Load(rawDataName);
}
catch (Exception Excp)
{
throw new Exception($"LoadWeatherData - " +
$"Es trat beim Laden der Wetterdaten von \"{rawDataName}" +
$"\" der folgende Fehler auf:\r\n{Excp}");
return false;
}
if (weatherData.DocumentElement == null)
return false;
weatherFileInfo.CreateDirectory_IfNotExists();
weatherFileInfo.Delete();
weatherData.Save(weatherFileInfo.FullName);
return true;
}
示例2: SaveAsFileDialog
/// <summary>Stores the image in the specified type under the specified folder, with the <paramref name="filename" />.</summary>
public static FileInfo SaveAsFileDialog(this BitmapSource image, string filename = null)
{
var dlg = new SaveFileDialog
{
FileName = filename ?? "Abbildung",
DefaultExt = ".png",
Filter = "PNG|*.png|JPG|*.jpg|GIF|*.gif|BMP|*.bmp|TIFF|*.tiff|WMP|*.wmp"
};
var result = dlg.ShowDialog();
if (result == true)
{
var fileInfo = new FileInfo(dlg.FileName);
fileInfo.CreateDirectory_IfNotExists();
fileInfo.AppendIndexToFile_IfExists();
var le = fileInfo.Extension.ToLower();
if (le == ".png")
image.SaveAs_PngFile(fileInfo);
if (le == ".jpg")
image.SaveAs_JpgFile(fileInfo);
if (le == ".gif")
image.SaveAs_GifFile(fileInfo);
if (le == ".bmp")
image.SaveAs_BmpFile(fileInfo);
if (le == ".tiff")
image.SaveAs_TiffFile(fileInfo);
if (le == ".wmp")
image.SaveAs_WmpFile(fileInfo);
return fileInfo;
}
return null;
}
示例3: WriteFile
private void WriteFile(FileInfo file, CsDbCodeNamespace codeNameSpace, FileTemplate content)
{
GeneratedFiles.Add(file.FullName);
if (file.Exists && IsFileUnchanged(file, content.GetHash()))
{
return;
}
file.CreateDirectory_IfNotExists();
codeNameSpace.Content = content.GetString(1);
using (var wr = new StreamWriter(file.FullName, false, Encoding.Unicode))
{
wr.Write(codeNameSpace.GetString());
}
}
示例4: CreateCacheFileInfo
static FileInfo CreateCacheFileInfo(PlayerMaterialType MaterialTyp, String materialNameId, String nameId, String extension)
{
String guidDirectory = $"{WPMediaLocalCacheRootDirectory}\\{ PlayerCache}\\{MaterialTyp}\\Dynamic";
String FullFileName = (String.IsNullOrEmpty(nameId))
? $"{guidDirectory}\\{materialNameId}.{extension}"
: $"{guidDirectory}\\{materialNameId}_{ConvertToCorrectFileNameElement(nameId)}.{extension}";
FileInfo result = new FileInfo(FullFileName);
result.CreateDirectory_IfNotExists();
return result;
}
示例5: GetSenderPlaylistLogFileName
public static String GetSenderPlaylistLogFileName(String senderName)
{
FileInfo fileInfo = new FileInfo(Path.Combine(WPMediaLocalCacheRootDirectory, $"{PlayerCache}\\", $"{senderName}\\{senderName}.PlayListDebug"));
fileInfo.CreateDirectory_IfNotExists();
return fileInfo.FullName;
}
示例6: CreatePlayListCacheFileInfo
public static FileInfo CreatePlayListCacheFileInfo(Guid playListId, String nameId)
{
String guidString = $"{playListId}";
String guidDirectory = $"{WPMediaLocalCacheRootDirectory}\\{PlayerCache}\\{PlayerMaterialType.Playlists}" +
$"\\{guidString.Substring(0, 2)}";
String FullFileName = (String.IsNullOrEmpty(nameId))
? $"{guidDirectory}\\{guidString}.PlayList"
: $"{guidDirectory}\\{guidString}_{ConvertToCorrectFileNameElement(nameId.Replace(" ", "_"))}.PlayList";
FileInfo result = new FileInfo(FullFileName);
result.CreateDirectory_IfNotExists();
return result;
}
示例7: CheckOldToNewConverter
public void CheckOldToNewConverter(String protokollFileName = null)
{
Data.DbServer3.AltErlaaInfo.LoadAll_IfHasNotBeenLoaded();
Data.DbServer3.AltErlaaInfo.Timings.LoadAllTimings();
Data.DbServer3.WPMedia.LoadAll_IfHasNotBeenLoaded();
Data.DbServer3.WPMedia.Timings.Load_TimingsAfter();
Data.DbServer3.WPMediaAddOnData.LoadAll_IfHasNotBeenLoaded();
Data.DbServer3.WPMediaAddOnData.Timings.LoadAllTimings();
Data.DbServer3.MultiMedia.LoadAll_IfHasNotBeenLoaded();
Data.DbServer3.MultiMedia.MMUnitTimings.LoadAllTimings();
Data.DbServer3.MultiMedia.MMUnits.Load_All_ShortData();
Dictionary<Guid, List<TabellenBasics>> allWPMediaAddOnData
= Data.DbServer3.WPMediaAddOnData.GetAllWPMediaAddOnData();
Dictionary<Guid, Dictionary<DateTime, int>> allWPMediaAddOnDataWithDuplicateModifyTimeStamps
= Data.DbServer3.WPMediaAddOnData.GetAllWPMediaAddOnDataWithDuplicateModifyTimeStamps();
StreamWriter protokollFile = null;
StreamWriter dataFile = null;
if (!String.IsNullOrEmpty(protokollFileName))
{
FileInfo fileInfo = new FileInfo(protokollFileName);
fileInfo.CreateDirectory_IfNotExists();
fileInfo.DeleteFile_IfExists();
protokollFile = new StreamWriter(protokollFileName);
FileInfo dataFileInfo = new FileInfo(protokollFileName.Replace(".log", ".data"));
dataFileInfo.CreateDirectory_IfNotExists();
dataFileInfo.DeleteFile_IfExists();
dataFile = new StreamWriter(dataFileInfo.FullName);
protokollFile.WriteLine($"StartZeit = {DateTime.Now}");
dataFile.WriteLine($"StartZeit = {DateTime.Now}");
}
CheckProcessConnectorenToWPMediaAddOnAnBeitraege(allWPMediaAddOnData, protokollFile, dataFile);
CheckWPMediaAddOnAnBeitraegetoProcessConnectoren(allWPMediaAddOnData, protokollFile, dataFile);
/*
CheckWPMediaAddOnDataTimings(allWPMediaAddOnData, protokollFile, dataFile);
CheckWPMediaAddOnData(allWPMediaAddOnData, allWPMediaAddOnDataWithDuplicateModifyTimeStamps,
protokollFile, dataFile);
CheckWPMedia(protokollFile, dataFile);
CheckMMUnits(protokollFile, dataFile);
*/
if (protokollFile != null)
{
protokollFile.WriteLine($"EndZeit = {DateTime.Now}");
dataFile.WriteLine($"EndZeit = {DateTime.Now}");
protokollFile.Close();
dataFile.Close();
}
}