The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.
Forum Discussion
Koemets
3 years agoContributor
Documents\Public location
Got a task to copy certain file from FileShare to Documents\Public because users security settings. Wanted to go with the standard System.IO.File.Copy(strSourceFile,strTargetFile) where source and ta...
- 3 years ago
The methods you need are under BRApi.Filesystem:
- BRApi.FileSystem.GetFile
BRApi.FileSystem.InsertOrUpdateFile - BRApi.FileSystem.GetFileShareFolder
Here's a mock example that just copies a file from a user's document folder and changes the name. You'll need to swap the sourceFile/sourceDir pieces with FileShare pieces from BRApi.FileSystem.GetFileShareFolder according to your needs.
'Source file Dim sourceFile As String = "SomeCSV.csv" Dim sourceDir As String = $"Documents/Users/{StringHelper.RemoveInvalidNameCharacters(si.UserName,False,False)}" 'Target File Dim targetFile As String = "CopiedFile.csv" Dim targetDir As String = sourceDir 'Get the file Dim sourceXFFileEx As New XFFileEx sourceXFFileEx = BRApi.FileSystem.GetFile(si, FileSystemLocation.ApplicationDatabase, sourceDir & "/" & sourceFile,True,True) 'Save the file Dim targetFileDataInfo As New XFFileInfo(FileSystemLocation.ApplicationDatabase, targetFile, targetDir) Dim targetFileData As New XFFile(targetFileDataInfo, String.Empty, sourceXFFileEx.XFFile.ContentFileBytes) BRApi.FileSystem.InsertOrUpdateFile(si, targetFileData) - BRApi.FileSystem.GetFile
Koemets
3 years agoContributor
Unfortunately not š
OS object doesn't seem to have a method to copy the files, and standard IO needs full path. Meaning the /consolidation folder is being created by OS Framework which still doesn't return the full path, necessary to copy the file by the IO.