0

我可以使用以下方法通过 NSURL 访问我的本地文件:

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://localhost/Users/user/Desktop/lucky_numbers.json"]];  

但我需要访问另一台 PC 的文件。我试过:

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://foyzulkarim:000000@192.168.1.48/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]];

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://192.168.1.48/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]];

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://Foyzul-Karims-MacBook.local/localhost/Users/foyzulkarim/Desktop/lucky_numbers.json"]];

但错误显示NSURLError domain code -1100

如果有人知道如何做到这一点,请帮助我。

4

2 回答 2

2

我不是那样工作的。file:URI 方案只支持本地文件访问,不支持远程。对于远程访问,您需要一个真实的网络协议,如 HTTP 或 FTP,因此需要远程站点上的服务器。

于 2011-03-08T10:05:12.360 回答
0

您可以使用以下方法通过 NSURL 访问我的本地文件: NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"file://192.168.1.48/localhost/Volumes/foyzulkarim/Desktop/lucky_numbers.json"]];

但是,要做到这一点,您必须先手动连接该 PC。

于 2011-06-01T07:04:01.273 回答