我已经编写了一些代码,这些代码应该在文件中逐行存储字符串数组中的一些字符串,遗憾的是我必须为数组中的大约200k字符串执行此操作,这需要我永远...
foreach (var file in fileArray) {
// Console.WriteLine(file);
string sub = file.Substring(49,file.Length - 49);
using (StreamWriter sw = File.AppendText(folder + ".tfcs"))
{
sw.WriteLine(sub);
}
indexfiles++;
Console.Clear();
Console.WriteLine("Scanning Folder:");
Console.WriteLine(folder);
Console.WriteLine("Filesfound:" + fileArray.Length);
Console.WriteLine("Fileswritten to Database:" + indexfiles);
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法改善这个?
PS我已经获得了已写入文件的字符串数量的进度...
概括:
我将进入下面的杂草,但基本上我的最终目标是从 AWS Lambda 函数检索值并将其返回到我的页面的客户端。该页面使用 AWS Cognito 对用户进行身份验证,并在通过身份验证后发布到 API 网关端点以从我的 Lambda 函数(Lambda 查询 DynamoDB)检索数据。这是我正在努力解决的部分,因为我收到了 504(超时)错误。
我知道我的 Lambda 正确返回值,并且我的 API 理论上实现正确,或者至少它在 API 网关管理控制台的测试部分工作。
细节:
我花了很多时间试图找出我的错误所在,我相信这与 Cognito 身份验证或 CORS 有关。如果我从我的 API 网关方法中删除授权要求并且不发送授权令牌,那么我会从帖子中得到预期的响应。这让我相信我的问题的根源可能是在 Post 方法上错误地实现了 Cognito 授权。
我使用 CORS 是因为该站点托管在 EC2 上,但其 RESTful 路由使用 AWS API Gateway。
此外,我使用 Cognito javascript SDK 对用户进行身份验证,然后将 authToken 传递到我的 ajax 中的自定义标头中。
这是我的 ajax:
$.ajax({
method: 'POST',
url: _config.api.invokeUrl + '/getusersites',
dataType: "json",
crossDomain: true,
cors: true,
xhrFields: {
withCredentials: true
},
headers: {
Authorization: token
},
data: JSON.stringify(user), …Run Code Online (Sandbox Code Playgroud)