我正在使用c#程序下载一个zip文件,我收到错误
at System.IO.Compression.ZipArchive.ReadEndOfCentralDirectory()
at System.IO.Compression.ZipArchive.Init(Stream stream, ZipArchiveMode mode,
Boolean leaveOpen)
at System.IO.Compression.ZipArchive..ctor(Stream stream, ZipArchiveMode mode,
Boolean leaveOpen, Encoding entryNameEncoding)
at System.IO.Compression.ZipFile.Open(String archiveFileName, ZipArchiveMode
mode, Encoding entryNameEncoding)
at System.IO.Compression.ZipFile.ExtractToDirectory(String sourceArchiveFileN
ame, String destinationDirectoryName, Encoding entryNameEncoding)
at System.IO.Compression.ZipFile.ExtractToDirectory(String sourceArchiveFileN
ame, String destinationDirectoryName)
Run Code Online (Sandbox Code Playgroud)
这是程序
response = (HttpWebResponse)request.GetResponse();
Stream ReceiveStream = response.GetResponseStream();
byte[] buffer = new byte[1024];
FileStream outFile = new FileStream(zipFilePath, FileMode.Create);
int bytesRead;
while ((bytesRead = ReceiveStream.Read(buffer, 0, buffer.Length)) != 0)
outFile.Write(buffer, 0, bytesRead);
outFile.Close();
response.Close();
try
{
ZipFile.ExtractToDirectory(zipFilePath, destnDirectoryName);
}
catch …Run Code Online (Sandbox Code Playgroud) 我对 AWS s3 存储桶概念有点陌生。我想从 s3 存储桶中的文件夹“TODAY FILE1”下载文件并使用它。我知道如何使用命令提示符在命令行中执行此操作。我不知道如何在 C# 中实现。
认为
这是我在命令提示符下执行的操作
C:\> aws s3 cp "s3://mys3bucket-output/TODAY FILE1" . --recursive
Run Code Online (Sandbox Code Playgroud)
这就是我做的 C# 程序并得到错误
string accessKey = "abc123";
string secretKey = "secret123";
string bucketName = "mys3bucket-output"
TransferUtility fileTransferUtility = new TransferUtility(new AmazonS3Client(accessKey, secretKey, Amazon.RegionEndpoint.USEast2));
BasicAWSCredentials basicCredentials = new BasicAWSCredentials(accessKey,secretKey);
AmazonS3Client s3Client = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey), Amazon.RegionEndpoint.USEast2);
ListObjectsRequest request = new ListObjectsRequest();
ListObjectsResponse response = s3Client.ListObjects(request.BucketName= bucketName, request.Prefix="TODAY FILE1/");
foreach (S3Object obj in response.S3Objects)
{
try
{
Console.WriteLine("{0}", obj.Key);
fileTransferUtility.Download(@"C:\Temp", bucketName, obj.Key); …Run Code Online (Sandbox Code Playgroud) 我有一个非常大的文本文件,大小为250 GB,由供应商提供给我们.它们还为我们提供了一个控制文件,该文件应该包含大文件中的行数.有时会出现不匹配的情况.我如何计算Powershell中的线条?我尝试了这个命令,它运行了半个多小时,但还没有完成.
Get-content C:\test.txt | Measure-Object –Line
(gc C:\test.txt | Measure-object | select count).count
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏谢谢MR
我有一个要求,我需要从这个HTML获取链接
"<span class=""name""><a href=Details.aspx?entityID=1&hash=20&searchFunctionID=53b&type=Advanced&nameSet=Entities&q=a&textSearchType=ExactPhrase&orgTypes=01%2c02%2c03%2c04%2c05%2c06%2c07%2c08%2c09%2c10%2c11%2c12%2c13%2c14%2c15%2c16%2c90%2c96%2c98%2c99> GOOGLE CORPORATION </a> </span> <br /> <span class=typeDescription> 09 - Analytics Company </span>"
Run Code Online (Sandbox Code Playgroud)
我需要的输出是
Details.aspx?entityID=1&hash=20&searchFunctionID=53b&type=Advanced&nameSet=Entities&q=a&textSearchType=ExactPhrase&orgTypes=01%2c02%2c03%2c04%2c05%2c06%2c07%2c08%2c09%2c10%2c11%2c12%2c13%2c14%2c15%2c16%2c90%2c96%2c98%2c99
Run Code Online (Sandbox Code Playgroud)
我用了
string sPattern ="[<a href=](.*?(99))";
MatchCollection mcMatches = Regex.Matches(input,sPattern);
foreach (Match m in mcMatches)
{
Console.WriteLine(m.Value);
}
Run Code Online (Sandbox Code Playgroud)
这不是给我正确的输出.任何人都可以指出我正确的方向.