C# Path.GetTempFileName的代码示例
Path.GetTempFileName方法的主要功能描述
通过代码示例来学习C# Path.GetTempFileName方法
通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。
Path.GetTempFileName是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的Path.GetTempFileName() 已经帮大家高亮显示了,大家可以重点学习Path.GetTempFileName() 方法的写法,从而快速掌握该方法的应用。
Path.GetTempFileName的代码示例1 - DigitalySignBootstrapperEngine()
using System.IO;
///
/// Applies digital signature to a bootstrapper engine with MS SignTool.exe utility.
/// Note : this method doesn't sign the bootstrapper file but the engine only.
/// Please use for signing both (bootstrapper and bootstrapper engine) instead.
/// See more about Bootstrapper engine signing
///
/// The Bootstrapper file to sign.
/// Specify the signing certificate in a file. If this file is a PFX with a password, the password may be supplied
/// with the password parameter.
/// The timestamp server's URL. If this option is not present (pass to null), the signed file will not be timestamped.
/// A warning is generated if timestamping fails.
/// The password to use when opening the PFX file. Should be null if no password required.
/// Extra arguments to pass to the SignTool.exe utility.
/// The optional ';' separated list of directories where SignTool.exe can be located.
/// If this parameter is not specified WixSharp will try to locate the SignTool in the built-in well-known locations (system PATH)
/// Type of the certificate store to load it from.
/// A flag indicating the output level
/// the hash algorithm to use. SHA1, SHA256, or both. NOTE: MSIs only allow
/// a single signature. If SHA1 | SHA256 is requested, the MSI will be signed with SHA1 only.
///
/// Exit code of the SignTool.exe process.
///
/// The following is an example of signing SetupBootstrapper.exe file engine.
///
/// WixSharp.CommonTasks.Tasks.DigitalySignBootstrapperEngine(
/// "SetupBootstrapper.exe",
/// "MyCert.pfx",
/// "http://timestamp.verisign.com/scripts/timstamp.dll",
/// "MyPassword",
/// null);
///
///
static public int DigitalySignBootstrapperEngine(string bootstrapperFileToSign, string pfxFile, string timeURL, string password,
string optionalArguments = null, string wellKnownLocations = null, StoreType certificateStore = StoreType.file, SignOutputLevel outputLevel = SignOutputLevel.Verbose, HashAlgorithmType hashAlgorithm = HashAlgorithmType.sha1)
{
var insigniaPath = IO.Path.Combine(Compiler.WixLocation, "insignia.exe");
string enginePath = IO.Path.GetTempFileName();
try
{
var tool = new ExternalTool
{
ExePath = insigniaPath,
Arguments = "-ib \"{0}\" -o \"{1}\"".FormatWith(bootstrapperFileToSign, enginePath)
};
var retval = tool.ConsoleRun();
if (retval != 0)
return retval;
retval = DigitalySign(enginePath, pfxFile, timeURL, password, optionalArguments, wellKnownLocations, certificateStore, outputLevel, hashAlgorithm);
if (retval != 0)
return retval;
tool = new ExternalTool
{
ExePath = insigniaPath,
Arguments = "-ab \"{1}\" \"{0}\" -o \"{0}\"".FormatWith(bootstrapperFileToSign, enginePath)
};
tool.ConsoleRun();
return retval;
}
finally
{
IO.File.Delete(enginePath);
}
}
开发者ID: oleg-shilo, 项目名称: wixsharp, 代码行数: 70, 代码来源: CommonTasks.cs
在oleg-shilo提供的DigitalySignBootstrapperEngine()方法中,该源代码示例一共有70行, 其中使用了Path.GetTempFileName()1次, 并且小编将这些方法高亮显示出来了,希望对您了解Path.GetTempFileName()有帮助。 如果您觉得有帮助的话,请帮忙点赞或转发。
该代码示例的点赞次数为3, 点赞数越大, 从某种程度说明这个示例对了解Path.GetTempFileName()可能更有帮助。
Path.GetTempFileName的代码示例2 - Fix_Issue_1171()
[Fact]
[Description("Issue #1171")]
public void Fix_Issue_1171()
{
var tempFile = System.IO.Path.GetTempFileName();
try
{
System.IO.File.WriteAllLines(tempFile, new[]
{
"Windows Registry Editor Version 5.00",
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Test]",
"\"New Value #1\"=dword:00000001",
"\"New Value #2\"=hex(b):02,00,00,00,00,00,00,00",
});
var values = WixSharp.RegFileImporter.ImportFrom(tempFile);
}
finally
{
tempFile.DeleteIfExists();
}
}
开发者ID: oleg-shilo, 项目名称: wixsharp, 代码行数: 22, 代码来源: IssueFixesTest.cs
在oleg-shilo提供的Fix_Issue_1171()方法中,该源代码示例一共有22行, 其中使用了Path.GetTempFileName()1次, 并且小编将这些方法高亮显示出来了,希望对您了解Path.GetTempFileName()有帮助。 如果您觉得有帮助的话,请帮忙点赞或转发。
该代码示例的点赞次数为3, 点赞数越大, 从某种程度说明这个示例对了解Path.GetTempFileName()可能更有帮助。
Path.GetTempFileName的代码示例3 - EditInExternalProgram()
using System.IO;
private void EditInExternalProgram(bool UseDefaultEditor = true)
{
if (!ActiveTexture.CanEdit || !IsFinished)
return;
ImageProgramSettings settings = new ImageProgramSettings();
settings.LoadImage(ActiveTexture);
if (settings.ShowDialog() == DialogResult.OK)
{
UseDefaultEditor = !settings.OpenDefaultProgramSelection;
string UseExtension = settings.GetSelectedExtension();
FormatToChange = settings.GetSelectedImageFormat();
string TemporaryName = Path.GetTempFileName();
Utils.DeleteIfExists(Path.ChangeExtension(TemporaryName, UseExtension));
File.Move(TemporaryName, Path.ChangeExtension(TemporaryName, UseExtension));
TemporaryName = Path.ChangeExtension(TemporaryName, UseExtension);
switch (UseExtension)
{
case ".dds":
ActiveTexture.SaveDDS(TemporaryName, true, false, CurArrayDisplayLevel, CurMipDisplayLevel);
break;
case ".astc":
ActiveTexture.SaveASTC(TemporaryName, true, false, CurArrayDisplayLevel, CurMipDisplayLevel);
break;
case ".tga":
ActiveTexture.SaveTGA(TemporaryName, true, false, CurArrayDisplayLevel, CurMipDisplayLevel);
break;
default:
ActiveTexture.SaveBitMap(TemporaryName, true, false, CurArrayDisplayLevel, CurMipDisplayLevel);
break;
}
//Start watching for changes
FileWatcher.EnableRaisingEvents = true;
FileWatcher.Filter = Path.GetFileName(TemporaryName);
if (UseDefaultEditor)
Process.Start(TemporaryName);
else
ShowOpenWithDialog(TemporaryName);
}
}
开发者ID: KillzXGaming, 项目名称: Switch-Toolbox, 代码行数: 46, 代码来源: ImageEditorBase.cs
在KillzXGaming提供的EditInExternalProgram()方法中,该源代码示例一共有46行, 其中使用了Path.GetTempFileName()1次, 并且小编将这些方法高亮显示出来了,希望对您了解Path.GetTempFileName()有帮助。 如果您觉得有帮助的话,请帮忙点赞或转发。
该代码示例的点赞次数为3, 点赞数越大, 从某种程度说明这个示例对了解Path.GetTempFileName()可能更有帮助。
Path.GetTempFileName的代码示例4 - MergeAll()
using System.IO;
public static void MergeAll(List Files, string output, ProgressLog Log)
{
int Check = Log.PushActivity("Gerber MergeAll");
if (Files.Count > 1)
{
MultiMerge(Files[0], Files.Skip(1).ToList(), output, Log);
Log.PopActivity(Check);
return;
}
if (Files.Count < 2)
{
if (Files.Count == 1)
{
Log.AddString("Merging 1 file is copying... doing so...");
if (File.Exists(output)) File.Delete(output);
File.Copy(Files[0], output);
}
else
{
Log.AddString("Need files to do anything??");
}
Log.PopActivity(Check);
return;
}
List TempFiles = new List();
if (true)
{
List LeftOverFiles = new List();
foreach (var a in Files)
{
LeftOverFiles.Add(a);
}
while (LeftOverFiles.Count > 1)
{
Log.AddString(String.Format("{0} files left in mergequeue", LeftOverFiles.Count));
string File1 = LeftOverFiles[0];
string File2 = LeftOverFiles[1];
LeftOverFiles.Remove(File1);
LeftOverFiles.Remove(File2);
string NewFile = Path.GetTempFileName();
Merge(File1, File2, NewFile, Log);
TempFiles.Add(NewFile);
LeftOverFiles.Add(NewFile);
}
if (File.Exists(output)) File.Delete(output);
File.Move(LeftOverFiles[0], output);
}
else
{
string LastFile = Files[0];
for (int i = 1; i < Files.Count - 1; i++)
{
string NewFile = Path.GetTempFileName();
TempFiles.Add(NewFile);
Merge(LastFile, Files[i], NewFile, Log);
LastFile = NewFile;
}
if (File.Exists(output)) File.Delete(output);
Merge(LastFile, Files.Last(), output, Log);
}
Log.AddString("Removing merge tempfiles");
foreach (string s in TempFiles)
{
try
{
File.Delete(s);
}
catch (Exception) { }
}
Log.PopActivity(Check);
}
开发者ID: ThisIsNotRocketScience, 项目名称: GerberTools, 代码行数: 79, 代码来源: GerberMerger.cs
在ThisIsNotRocketScience提供的MergeAll()方法中,该源代码示例一共有79行, 其中使用了Path.GetTempFileName()2次, 并且小编将这些方法高亮显示出来了,希望对您了解Path.GetTempFileName()有帮助。 如果您觉得有帮助的话,请帮忙点赞或转发。
该代码示例的点赞次数为3, 点赞数越大, 从某种程度说明这个示例对了解Path.GetTempFileName()可能更有帮助。
Path.GetTempFileName的代码示例5 - OnSelectedStreamChanged()
using System.IO;
///
/// Called by the view to notify of a change in the selection of the SelectedStreamInfo.
///
public void OnSelectedStreamChanged()
{
if (View.SelectedStreamInfo != null && this.SelectedMsiFile != null)
{
// 1: find the right stream containing the cab bits:
using (var oleFile = new OleStorageFile(new LessIO.Path(this.SelectedMsiFile.FullName)))
{
var foundStream = oleFile.GetStreams().FirstOrDefault(s => string.Equals(View.SelectedStreamInfo.Name, s.Name, StringComparison.InvariantCulture));
if (foundStream == null)
{
View.ShowUserError("Could not find stream for CAB '{0}'", View.SelectedStreamInfo.Name);
return;
}
// if the file is a cab, we'll list the files in it (if it isn't clear the view):
IEnumerable streamFiles = new CabContainedFileView[]{};
if (View.SelectedStreamInfo.IsCabStream)
{
var tempFileName = System.IO.Path.GetTempFileName();
using (var cabBits = foundStream.GetStream(FileMode.Open, FileAccess.Read))
using (var writer = new BinaryWriter(File.Create(tempFileName)))
{
var buffer = new byte[1024*1024];
int bytesRead;
do
{
bytesRead = cabBits.Read(buffer, 0, buffer.Length);
writer.Write(buffer, 0, bytesRead);
} while (bytesRead > 0);
}
// 2: enumerate files in the cab and set them to the view's
using (var cab = new LibMSPackN.MSCabinet(tempFileName))
{
// ToList to force it to enumerate now.
streamFiles = cab.GetFiles().Select(f => new CabContainedFileView(f.Filename)).ToList();
}
Debug.Assert(streamFiles != null && streamFiles.Any());
}
View.SetCabContainedFileListSource(streamFiles);
}
}
}
开发者ID: activescott, 项目名称: lessmsi, 代码行数: 47, 代码来源: MainFormPresenter.cs
在activescott提供的OnSelectedStreamChanged()方法中,该源代码示例一共有47行, 其中使用了Path.GetTempFileName()1次, 并且小编将这些方法高亮显示出来了,希望对您了解Path.GetTempFileName()有帮助。 如果您觉得有帮助的话,请帮忙点赞或转发。
该代码示例的点赞次数为3, 点赞数越大, 从某种程度说明这个示例对了解Path.GetTempFileName()可能更有帮助。
Path.GetTempFileName的代码示例6 - PerformAppxWorkloadInstallation()
using System.IO;
public bool PerformAppxWorkloadInstallation(string ospath, string repositoryPath, string licenseFolder, AppxInstallWorkload workload)
{
bool result = true;
//
// Initialize DISM log
//
string tempLog = Path.GetTempFileName();
DismApi.Initialize(DismLogLevel.LogErrorsWarningsInfo, tempLog);
DismSession session = DismApi.OpenOfflineSession(ospath);
try
{
DismApi.AddProvisionedAppxPackage(
session,
Path.Combine(repositoryPath, workload.AppXPath),
workload.DependenciesPath?.Select(x => Path.Combine(repositoryPath, x)).ToList() ?? new List(),
string.IsNullOrEmpty(workload.LicensePath) ? null : Path.Combine(licenseFolder, workload.LicensePath),
null,
string.IsNullOrEmpty(workload.StubPackageOption) ? DismStubPackageOption.None : DismStubPackageOption.InstallStub); // TODO: proper handling
}
catch { result = false; }
//
// Clean DISM
//
try
{
DismApi.CloseSession(session);
}
catch { }
try
{
DismApi.Shutdown();
}
catch { }
try
{
File.Delete(tempLog);
}
catch { }
return result;
}
开发者ID: gus33000, 项目名称: UUPMediaCreator, 代码行数: 49, 代码来源: DismOperations.cs
在gus33000提供的PerformAppxWorkloadInstallation()方法中,该源代码示例一共有49行, 其中使用了Path.GetTempFileName()1次, 并且小编将这些方法高亮显示出来了,希望对您了解Path.GetTempFileName()有帮助。 如果您觉得有帮助的话,请帮忙点赞或转发。
该代码示例的点赞次数为3, 点赞数越大, 从某种程度说明这个示例对了解Path.GetTempFileName()可能更有帮助。
Path.GetTempFileName()方法的常见问题及解答
C#中Path.GetTempFileName()的常见错误类型及注意事项
Path.GetTempFileName的错误类型有很多, 这里就不一一阐述了,本文只列出一些常见的代码示例供参考,大家可以看一下代码中Catch语句中是否有常见的错误捕获及处理。
C#中Path.GetTempFileName()的构造函数有哪些
Path.GetTempFileName构造函数功能基本类似,只是参数不同; 目前主流的集成开发环境都已经带智能提醒了,如:Visual Studio; 大家可以非常轻松的通过Visual Studio中的智能提醒,了解对应构造函数的用法。
如何使用ChartGPT写一段Path.GetTempFileName的代码
你可以在ChartGPT中输入如下的指令:"提供一个如何使用Path.GetTempFileName的C#代码示例"
ChartGPT写出的代码和本文中的小编提供的代码的区别。 ChartGPT发展到现在已经非常聪明了,但需要使用这提供非常专业的问题,才可能有比较好的源代码示例; 而本文中, 小编已经帮您列出来基本所有类和所有方法的使用示例, 而且这些示例基本都是一些网络大佬提供的源码,可以更方便的供一些开发菜鸟或者资深开发参考和学习。
Path.GetTempFileName所在的类及名称空间
Path.GetTempFileName是System.IO下的方法。
Path.GetTempFileName怎么使用?
Path.GetTempFileName使用上比较简单,可以参考MSDN中的帮助文档,也参考本文中提供的7个使用示例。
Path.GetTempFileName菜鸟教程
对于菜鸟来说,本文中提供的7个Path.GetTempFileName写法都将非常直观的帮您掌握Path.GetTempFileName的用法,是一个不错的参考教程。
本文中的Path.GetTempFileName方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。