B4J Question file.dirapp permission error

Douglas Farias

Expert
Licensed User
Longtime User
B4X:
    target = File.DirApp
    File.MakeDir(target, "Arquivos_Recebidos")
    fp = File.Combine(target,"Arquivos_Recebidos" )

i made this code to make a folder of my .jar
my .jar receiv files from the android and store this file on this folder.

but i dont understand why i have permission error when i try save itens on this folder
if i dont use fp this works only file.dirapp but if i use file.dirapp & "Arquivos_Recebidos" = fp
i have this error log
Program started.
asyncstreamsobject._astream_newstream (java line: 138)
java.lang.RuntimeException: java.lang.RuntimeException: java.io.FileNotFoundException: C:\Users\Douglas\Desktop\MEUSAP~1\EMDESE~1\ABOOPC~1\pc\Objects\Arquivos_Recebidos (Acesso negado)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:455)
at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:424)
at b4j.example.asyncstreamsobject._astream_newstream(asyncstreamsobject.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.BA$3.run(BA.java:178)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/7929364.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/7135120.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/24247422.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: C:\Users\Douglas\Desktop\MEUSAP~1\EMDESE~1\ABOOPC~1\pc\Objects\Arquivos_Recebidos (Acesso negado)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:446)
... 18 more
Caused by: java.io.FileNotFoundException: C:\Users\Douglas\Desktop\MEUSAP~1\EMDESE~1\ABOOPC~1\pc\Objects\Arquivos_Recebidos (Acesso negado)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:345)
at anywheresoftware.b4a.objects.streams.File.Copy(File.java:318)
at b4j.example.main._astreamo_newobject(main.java:203)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
... 19 more

why this?
how can i make a fixed folder to save my files under the pc? i want to save this in a folder.
thx
 

Douglas Farias

Expert
Licensed User
Longtime User
yes i can open
C:\Users\Douglas\Desktop\MEUSAP~1\EMDESE~1\ABOOPC~1\pc\Objects\Arquivos_Recebidos
is the file.dirapp with only a folder, its possible store files in a folder on file.dirapp?
the error is permission, but where i add permission at b4j?
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
@Erel have this error log

File.Copy(astreamO.TempFolder, fileName, "c:\test", Key.SubString(8))

B4X:
Program started.
EXISTE
asyncstreamsobject._astream_newstream (java line: 136)
java.lang.RuntimeException: java.lang.RuntimeException: java.io.FileNotFoundException: c:\test (Acesso negado)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:455)
    at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:424)
    at b4j.example.asyncstreamsobject._astream_newstream(asyncstreamsobject.java:136)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    at anywheresoftware.b4a.BA$3.run(BA.java:178)
    at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
    at com.sun.javafx.application.PlatformImpl$$Lambda$47/17912246.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
    at com.sun.javafx.application.PlatformImpl$$Lambda$46/7135120.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
    at com.sun.glass.ui.win.WinApplication$$Lambda$37/24247422.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: c:\test (Acesso negado)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:114)
    at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:446)
    ... 18 more
Caused by: java.io.FileNotFoundException: c:\test (Acesso negado)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:345)
    at anywheresoftware.b4a.objects.streams.File.Copy(File.java:318)
    at b4j.example.main._astreamo_newobject(main.java:206)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
    ... 19 more
 
Last edited:
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
really, i m noob i forgot to send a arquivo:filenamehere, i have fixed thx erel
 
Upvote 0
Top