Delphi XE5 - Android - 在服务器窗口中保存文件(共享文件夹)

时间:2014-02-22 10:16:22

标签: java android delphi delphi-xe5

早上好,

我在Android上通过Delphi XE5开发了一个应用程序,它尝试将文本文件保存在服务器上的共享文件夹中(窗口)但是我收到了消息I / O错误30.我我在代码中描述的Assign File中尝试了几种方法。可以帮忙吗?

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;

2 个答案:

答案 0 :(得分:0)

使用TStringList对象,然后使用它的TStringList.SaveToFile()函数。

答案 1 :(得分:0)

如果不支持服务器端使用的网络协议,则无法做到这一点。对于Windows,有一个支持SMB协议的Android库。 Stackoverflow上的一些问题包括解释其使用和服务器身份验证的源代码,例如:

Write/upload a file using Samba/JCIFS issue (SmbAuthException: Access is denied)

有关介绍,请参阅

http://durgemeister.wordpress.com/2014/04/26/mapping-a-network-with-jcifs-and-android/