我想知道如何测试我是否可以访问字符串路径.这是我使用的代码:
using System;
using System.IO;
namescpace prog1
{
class Program
{
static void Main(string[] args)
{
string path = @"C:\Users\Admin";
DirectoryInfo dir = new DirectoryInfo(path);
foreach (FileInfo fil in dir.GetFiles())
{
//At dir.GetFiles, I get an error saying
//access to the string path is denied.
Console.WriteLine(fil.Name);
}
Console.ReadLine();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想测试访问是否被拒绝(到字符串路径)然后执行GetFiles和所有这些.
我已经发现了这个问题:如何轻松检查.NET中的文件是否被拒绝访问?
有帮助吗?
我正在尝试打开一个索引的文件,但不断收到以下错误.从我能找到的所有COBOL代码示例中,我无法看到我的错误在哪里.
我能够按顺序打开文件就好了.它似乎是试图打开索引的东西.
错误:
project2.cbl:119: libcob: Permanent file error (STATUS = 30) File : 'customers.dat'
Run Code Online (Sandbox Code Playgroud)
系统:
OS X
GnuCOBOL
OpenCobolIDE
Version: 4.7.3
Run Code Online (Sandbox Code Playgroud)
码:
IDENTIFICATION DIVISION.
PROGRAM-ID. PROJECT-2.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT CUST-FILE ASSIGN TO "customers.dat"
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD KEY IS CUST-ID.
SELECT INV-FILE ASSIGN TO "inventory.dat"
ORGANIZATION IS INDEXED
ACCESS IS RANDOM
RECORD KEY IS ITEM-ID.
SELECT TRANS-FILE ASSIGN TO "transactions.dat"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT SORTED-TRANS-FILE ASSIGN TO "sorted-transactions.dat"
ORGANIZATION IS LINE SEQUENTIAL.
SELECT …Run Code Online (Sandbox Code Playgroud) 语境:
我正在编写一个网络服务器,我们在其中处理不同的段。我想将这些不同的段缓存在不同的文件中(段的大小最大可达 10MB)。像这样的东西:
pub async fn segment_handler(segment: String) {
if is_cached(&segment) {
return get_from_cache(segment)
}
// Do some computation to get the result.
let result = do_some_large_computation(segment);
// Cache this result to a file.
let file_name = &format!("./cache/{}", &segment);
fs::create(file_name);
fs::write(file_name, result).expect("Unable to write file");
result
}
Run Code Online (Sandbox Code Playgroud)
既然segment_handler可以被不同的多个线程调用segment,那么fs::write线程安全吗?如果没有,我们就不能使用互斥体,因为segment: String每次调用的互斥体可能不同,并且使用互斥体会使性能变差。我需要类似互斥体的东西,但仅需要segment: String。这个问题的解决办法是什么?
环境:
我有一个grails应用程序,它允许用户上传图像文件,并可以显示这些图像.应用程序实际上只将文件路径存储在数据库中,并将图像文件保存在文件系统中.
我读过一些帖子,说Cloud Foundry不支持本地文件系统访问.所以我的问题是,如果我想将我的应用程序部署到Cloud Foudry,我应该做哪些修改?我希望图像仍然可以直接显示在网页上,用户不必将它们下载到自己的计算机上进行查看.
file-access ×4
c# ×1
cobol ×1
concurrency ×1
gnucobol ×1
grails ×1
image-file ×1
indexed ×1
io ×1
rust ×1