I want to save my files within a folder but the issue which raising is that my files are storing outside of the folder which is annoying. I am sharing what I have done so far.

-- get raw path to app's Temporary directory
local doc_path = system.pathForFile( "", system.DocumentsDirectory )

-- change current working directory
local success = lfs.chdir( doc_path ) -- returns true on success
local new_folder_path

if success then
lfs.mkdir( "MyNewFolder" )
new_folder_path = lfs.currentdir() .. "/MyNewFolder"
end

local filePath = system.pathForFile( dataFileName , new_folder_path )
r = media.newRecording(filePath)
--print("new recording has been started with a name"..dataFileName)
r:startRecording()

but my recorded file is out of this newly created folder can someone help me here?

有帮助吗?

解决方案

I searched out and finally got the answer that the problem.This is how to create a new recording in specified folder

r = media.newRecording( new_folder_path.."/"..dataFileName )

This line would automatically create a file in this folder as mentioned in the question. system.pathForFile() only creates a file automatically when the second argument is a base directory like system.DocumentsDirectory (as it is clearly mentioned in the documentation that the second argument is constant and it should be only any base directory). so if you want to create a new file r want to find the path of the file you would append folder name before the file name like my folder/my file Hope this would help

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top