I can get the user to select a SharePoint folder but wasn't successful in looping through the files in selected SharePoint folder. However, I can make them select a LAN folder and loop through the files in the folder.
So, I my goal is to loop through a folder from SharePoint. I am currently using the solution from this post
But, I'm getting stuck with Error - "Runtime error 52 for bad file name or number"
my file is "Q:\https:\company.sharepoint.com\sites\Group\Sales\BD\Add\Sale 2022"
Thank you
Related
I developed a vb.net project and built it successfully. but while publishing, I got an error Unable to copy file "Resources\xxxxxxx.xlsx" to "bin\Release\app.publish\Application Files\aaaaaaaaaaaaaaaa_1_0_0_90\Resources\xxxxxxxx.xlsx.deploy". Could not find a part of the path 'bin\Release\app.publish\Application Files\aaaaaaaaaaaaaaaa_1_0_0_90\Resources\xxxxxxxx.xlsx.deploy'.
I couldnt find the reason for the issue. Tried reopening the project rebuilding and republishing several times.
I found the solution myself. The problem was the file name. The filename was too long. I saved the project inside Document folder within many sub folder. Thats why the filename became too long. I copied the project and placed insinde Documents folder directly and tried publishing. It was successfull.
Thank you
I have created a file structure within Microsoft Teams to support a sales forecasting tool. VBA routines access and modify these files as appropriate. I would like to check if a file exists in a target directory before attempting to open it and then handle any missing files within VBA. I cannot find a way of doing something analogous to the Dir instruction, e.g.
If Len(Dir("c:\Filename.xlsx")) = 0 Then Msgbox "This file does NOT exist."
Substituting the URL returns error 52 "Bad file name".
Opening and saving files works fine, but if the file is not present, I only get a system error which I cannot handle within my environment.
If you sync the files locally, you can go on with Dir and local path instead of url.
VBA - Access
I'm using fso.DeleteFolder to delete a folder on a server that an earlier function in the same Access DB created. The fso.DeleteFolder code runs without error and running fso.FolderExists after shows the folder no longer exists (prior to the delete, fso.FolderExists stated that the folder did exist).
However the folder is still listed in File Explorer on the server. Refreshing does no good. When double-clicking the folder on the server, I get an error stating that the folder is not accessible and access denied (prior to the delete, the folder was normal).
The folder may or may not have subfolders and/or files - but I do not think that is important because if I run the create / delete processes over again using a different folder name, the issue repeats - EXCEPT the prior folder is now no longer listed in File Explorer (truly deleted now as God intended), replaced with the new folder that was supposed to be deleted with the same double-click error and so on.
I kill my fso object at the end of the function, I believe the same issue also happens with KILL instead of fso.
Any help/thoughts would be appreciated.
Just encountered that problem!
For some reason deleting a directory with VBA leaves that lingering "lock" on the deleted file UNTIL it performs another directory type action then it flushes the "lock" If you were to delete three directories in one script you would likely find that the only "failed" delete action would be on the last directory deleted.
Performing a "directory read" type action within the script after the RmDir action works for me. Try something like this...
If Dir("yourpath") = "" Then MkDir "yourpath"
I have 3 xml file to be written to a folder for client. while writing the 2 files got written perfectly but 3rd file failed. what are the ways by which I can prevent the client to open any file or all the files got deleted or locked if anything failed?
If your application has delete privileges on the system, keep a record of the filenames to the files you're writing. If a file fails for whatever reason, go through the list of file names and delete the files from the directory. A simple string list with a for loop should do it.
This is a really odd security issue with a C# (3.0) Console application.
The application creates a folder and copies a bunch of files into that folder, it then also generates some files and saves them into the same folder. File streams are always closed. The copied files are done using File.Copy. Once the files are there, I don't seem to be able to access them again - later in the code, if I want to delete or open an existing file I get a access denied error yet I just created or copied the file there so I know I have permission!
Visual Studio 2008, Windows 7 (beta) - tried running as administrator but it didn't help. I also gave the parent folder permissions so that "Everyone" had write access and its under my logged in user documents folder.
Thanks!
update: I tried this on XP and had the same result so its not Win 7 :)
Have the files got the read-only attribute set? Trying to delete read-only files can cause an access denied exception to be thrown.
If you do all your stream declarations in a using block, you should be guaranteed they aren't causing the problem.