[英]CS1003 and CS1026 Syntax error when I trying to build
I'm not sure why I am getting this error.I am trying to build this on Visual Studio.I am new but i need to build this code.我不确定为什么会收到此错误。我正在尝试在 Visual Studio 上构建它。我是新手,但我需要构建此代码。
There are my errors and code :有我的错误和代码:
(30,19): error CS1003: Syntax error, '(' expected (30,19): 错误 CS1003: 语法错误, '(' 预期
(30,88): error CS1026: ) expected (30,88): 错误 CS1026: )
(31,19): error CS1003: Syntax error, '(' expected (31,19): 错误 CS1003: 语法错误, '(' 预期
(31,51): error CS1026: ) expected (31,51): 错误 CS1026:) 预期
(36,23): error CS1003: Syntax error, '(' expected (36,23): 错误 CS1003: 语法错误, '(' 预期
(36,63): error CS1026: ) expected (36,63): 错误 CS1026: )
(37,23): error CS1003: Syntax error, '(' expected (37,23): 错误 CS1003: 语法错误, '(' 预期
(37,156): error CS1026: ) expected (37,156): 错误 CS1026:) 预期
namespace MelonLoader.AssemblyGenerator
{
public static class DownloaderAndUnpacker
{
public static void Run(string url, string targetVersion, string currentVersion, string destinationFolder, string tempFile)
{
if (targetVersion == currentVersion)
{
Logger.Log($"{destinationFolder} already contains required version, skipping download");
return;
}
Logger.Log($"Cleaning {destinationFolder}");
foreach (var entry in Directory.EnumerateFileSystemEntries(destinationFolder))
{
if (Directory.Exists(entry))
Directory.Delete(entry, true);
else
File.Delete(entry);
}
Logger.Log($"Downloading {url} to {tempFile}");
Program.webClient.DownloadFile(url, tempFile);
Logger.Log($"Extracting {tempFile} to {destinationFolder}");
/*line 30*/ using var stream = new FileStream(tempFile, FileMode.Open, FileAccess.Read);
using var zip = new ZipArchive(stream);
foreach (var zipArchiveEntry in zip.Entries)
{
Logger.Log($"Extracting {zipArchiveEntry.FullName}");
using var entryStream = zipArchiveEntry.Open();
using var targetStream = new FileStream(Path.Combine(destinationFolder, zipArchiveEntry.FullName), FileMode.OpenOrCreate, FileAccess.Write);
entryStream.CopyTo(targetStream);
}
}
}
}
This seems to be C# 8 "using declarations";这似乎是 C# 8“使用声明”; it is possible that you have an up to date compiler available, but your csproj is configured to use down-level C#;
您可能有可用的最新编译器,但您的 csproj 配置为使用低级 C#; it is possible that editing the cspoj to update or add:
可以编辑 cspoj 来更新或添加:
<LangVersion>8</LangVersion>
(or higher, inside a <PropertyGroup>
element) (或更高,在
<PropertyGroup>
元素内)
would fix it.会修复它。
If you can't use C# 8, then:如果您不能使用 C# 8,则:
using (var stream = new FileStream(tempFile, FileMode.Open, FileAccess.Read))
using (var zip = new ZipArchive(stream))
{
foreach (var zipArchiveEntry in zip.Entries)
{
Logger.Log($"Extracting {zipArchiveEntry.FullName}");
using (var entryStream = zipArchiveEntry.Open())
using (var targetStream = new FileStream(Path.Combine(destinationFolder, zipArchiveEntry.FullName), FileMode.OpenOrCreate, FileAccess.Write))
{
entryStream.CopyTo(targetStream);
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.