Good morning,
I developed an application on Android
through the Delphi XE5
which tries to save a text file in a shared folder on the server (windows) but I received the message I / O error 30. I've tried several ways in Assign File
as describe in the code. Could help?
function gravar_registro():integer;
var NomeArqTxt: TextFile;
begin
try
begin
// AssignFile(NomeArqTxt, '/storage/sdcard1/FolderTEST/xxx.txt'); // Test1 OK = This is possible = OK = SDCARD
// AssignFile(NomeArqTxt, '/sdcard/FolderTEST/gerados/xxx.txt'); // Test2 OK = This is possible = OK = memória interna;
// AssignFile(NomeArqTxt, '\\192.168.1.152\FolderSHARED\xxx.txt'); // Test3 = ERROR = I've done testing, but I / O error 30
// AssignFile(NomeArqTxt, 'smb://192.168.1.152/FolderSHARED/xxx.txt'); // Test4 = ERROR = I've done testing, but I / O error 30
// AssignFile(NomeArqTxt, '192.168.1.152\FolderSHARED\xxx.txt'); // Test5 = ERROR = I've done testing, but I / O error 30
//. Observation: a) I've done testing with FolderSHARED folder and it has access to read / write
// b) The IP 192.168.1.152 is valid and active a personal computer on the internal network
{$I-}
Reset(NomeArqTxt);
{$I+}
if (IOResult <> 0) then
ReWrite(NomeArqTxt)
else
begin
CloseFile(NomeArqTxt);
Append(NomeArqTxt);
end;
Writeln(NomeArqTxt, 'TEST TEST TEST');
CloseFile(NomeArqTxt);
showmessage('File Saved...');
end
except
On Erro: Exception Do
begin
showmessage(Erro.Message);
end;
end;
end;
使用TStringList对象,然后使用它的TStringList.SaveToFile()函数。
This is not possible without support for the network protocol used on the server side. For Windows, there is an Android library to support the SMB protocol. Some questions on Stackoverflow included source code which explain its usage and authentication with the server, for example:
Write/upload a file using Samba/JCIFS issue (SmbAuthException: Access is denied)
For an introduction see
http://durgemeister.wordpress.com/2014/04/26/mapping-a-network-with-jcifs-and-android/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.