我有一个创建一个例程,将并行解压缩多个zip文件(zip的平均大小将是2GB).所以,我创建了一个使用TPL解压缩文件的函数.
这在原则上很有效.我还没有测试数据所以我想我会复制当前存在的zip文件并重命名其中的文件并重新压缩它.好吧,当我这样做时,我收到以下错误:
使用不受支持的压缩方法压缩归档条目
那么请你认为合适的代码评论,为什么我在这里得到错误.
码:
private static void UnzipfilesInTemp()
{
Task[] unzippers = null;
bool rtn = false;
//--UNZIP FILES IN TEMPORARY LOCATION
var TEMP_ZIP_FILES = System.IO.Directory.GetFiles(tempPath, "*" + Statement*.zip");
unzippers = new Task[TEMP_ZIP_FILES.Length];
unZippedFiles = new string[TEMP_ZIP_FILES.Length];
lock (thisLock)
{
for (int i = 0; i <= TEMP_ZIP_FILES.Length - 1; i++)
{
string filename = TEMP_ZIP_FILES[i];
unzippers[i] = Task.Factory.StartNew(() =>
{
//--UNZIP FILE FOR STATEMENT IMPORTING
try
{
ZipFile.ExtractToDirectory(filename, tempPath);
}
catch (Exception)
{
//--UNABLE TO UNZIP FILES
_coreprocess.AddLogDetailRecord(MSG, …
Run Code Online (Sandbox Code Playgroud) 我正在浏览大约 70 万行代码。大量的接口实现和DI使用。我试图找出从哪里调用特定方法,因此我尝试使用[CallerMemberName]
.
我在谷歌等上看到的所有例子都是这样的:
public void TraceMessage(string message,
[System.Runtime.CompilerServices.CallerMemberName] string memberName = "",
[System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "",
[System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0)
Run Code Online (Sandbox Code Playgroud)
可选参数用于获取信息。我的问题是这个方法是接口实现的一部分。因此,当我更改方法签名时,编译器会对我大喊大叫。
任何有关如何使接口方法发挥良好作用的建议[CallerMembername]
将不胜感激。
愚蠢的问题我明白了..但这两个陈述之间有什么区别
if( null == this.someVariable)
{
//do something
}
and
if( this.someVariable == null )
{
//do something.
}
Run Code Online (Sandbox Code Playgroud) 我正在学习/试验Async Await功能.我有一个调用此代码的按钮单击事件:
//first select the direcgtory in this event. Then called the async function..to be written
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
foldername = folderBrowserDialog1.SelectedPath;
}
// CreateFilesParellel();
var x = CreateAsync();
Run Code Online (Sandbox Code Playgroud)
以下是CreateAsync函数的样子:模式详细信息在此处
async Task<int> CreateAsync()
{
string fileType;
List<Task> tasks = new List<Task>();
//get the files in the existing directory.
var files = Directory.GetFiles(foldername);
fileType = Path.GetExtension(files[0]);
var filepath = Path.GetFullPath(files[0]);
string d = Path.GetDirectoryName(files[0]);
var ss = Path.GetFileNameWithoutExtension(files[0]);
var progress = new Progress<string>();
Stopwatch sw = new Stopwatch();
sw.Start(); …
Run Code Online (Sandbox Code Playgroud) 我有一个旧的 asp.net 应用程序,我升级到了 3DES 加密。我的开发机器当然工作正常,QA 工作正常(工作正常,因为加密和解密没有错误)。但是,当我将它部署到登台时,我无法让它工作。该应用程序开始抛出解密错误。
经过大量谷歌搜索后,我发现我必须在 web.config 中添加 compatibleMode="Framework20SP2"。
有人可以帮我理解这是什么吗?为什么我的应用程序可以在其他环境中运行。我知道这有效,但为什么我不明白?
c# ×4
.net ×1
3des ×1
asp.net ×1
async-await ×1
asynchronous ×1
if-statement ×1
unzip ×1
web-config ×1