B4J Question Save file to disk D:\

red30

Well-Known Member
Licensed User
Longtime User
Can I save files somewhere other than File.DirApp?
I tried it like this:
File.WriteList ("D: \", "file_name.txt", TEMP)
But the program crashes with the error:
B4X:
Saving changes...
main._writefile (java line: 822)
java.io.FileNotFoundException: D:\1_1_1_Full.txt (Отказано в доступе)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:439)
    at anywheresoftware.b4a.objects.streams.File.WriteList(File.java:247)
    at b4j.liana.write.nov.onesigcrc.main._writefile(main.java:822)
    at b4j.liana.write.nov.onesigcrc.main._timer1_tick(main.java:781)
    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:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:118)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    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$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)
How can I save the list, for example to the root of disk d?
 

Kiffi

Well-Known Member
Licensed User
Longtime User
Do you have write access to the file?

Is the file perhaps blocked by another process?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
I try to use: File.WriteList ("D:\", "file_name_Full.txt",TEMP)
Anyway, the same error:
B4X:
Saving changes...
main._writefile (java line: 822)
java.io.FileNotFoundException: D:\1_1_1_Full.txt (Отказано в доступе)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:439)
    at anywheresoftware.b4a.objects.streams.File.WriteList(File.java:247)
    at b4j.liana.write.nov.onesigcrc.main._writefile(main.java:822)
    at b4j.liana.write.nov.onesigcrc.main._timer1_tick(main.java:781)
    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:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:118)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    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$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)
I want to write the file to another hard disk, for example D:\.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
java.io.FileNotFoundException: D:\1_1_1_Full.txt (Отказано в доступе)
the error does not match the code you posted
I try to use: File.WriteList ("D:\", "file_name_Full.txt",TEMP)
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
the error does not match the code you posted
Sorry copied not from there.
File.WriteList ("D:\", "1_1_1_Full.txt",TEMP)
B4X:
Saving changes...
main._writefile (java line: 822)
java.io.FileNotFoundException: D:\1_1_1_Full.txt (Отказано в доступе)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:439)
    at anywheresoftware.b4a.objects.streams.File.WriteList(File.java:247)
    at b4j.liana.write.nov.onesigcrc.main._writefile(main.java:822)
    at b4j.liana.write.nov.onesigcrc.main._timer1_tick(main.java:781)
    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:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:118)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    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$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
I will code your code:
B4X:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
    
    Dim TEMP As List
    TEMP.Initialize
    TEMP.Add("Test")
    TEMP.Add("Test")
    TEMP.Add("Test")
    TEMP.Add("Test")
    
    File.WriteList ("D:\", "1_1_1_Full.txt",TEMP)
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
Same error:
B4X:
main._appstart (java line: 74)
java.io.FileNotFoundException: D:\1_1_1_Full.txt (Отказано в доступе)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at anywheresoftware.b4a.objects.streams.File.OpenOutput(File.java:439)
    at anywheresoftware.b4a.objects.streams.File.WriteList(File.java:247)
    at b4j.example.main._appstart(main.java:74)
    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:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at b4j.example.main.start(main.java:37)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    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$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
I understood, probably this disk was earlier system С:\. After I put ssd, and this disk became D:\
Is it possible to first check discs and the ability to record them? Is it possible to write files to С:\?
 
Upvote 0
Top