1

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;
mjn
  • 36,362
  • 28
  • 176
  • 378

2 Answers2

0

Use the TStringList object and then use it's TStringList.SaveToFile() function.

FMXExpress
  • 1,246
  • 8
  • 10
0

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/

jelmer
  • 2,405
  • 14
  • 27
mjn
  • 36,362
  • 28
  • 176
  • 378