Word-AddIn (VSTO) doesn't get the filepath from local OneDrive Folder - ms-word

I'm trying to develop an Word-AddIn where I can upload a file, or where I could make changes to the file itself. I can do that with any File on the Local NTFS Windows Filesystem. But when a File is located to any "OneDrive"-Folder it won't work, as the file-Document path starts with:
https://companyname-my.sharepoint.com/personal/name_whatever/Documents
according to the return values of:
var doc = Globals.ThisAddIn.Application.ActiveDocument;
MessageBox.Show("Document Name : " + doc.Name);
MessageBox.Show("Document Full Name : " + doc.FullName);
MessageBox.Show("Document Path : " + doc.Path);
rather than expected to be:
C:\Users\myname\OneDrive-My_Company_Name\Documents
So basically the local folder is not callable. So does anybody has already faced this kind of issue?

You can use the Save or SaveAs methods of the Document to save the document on the local folder.

Related

Cannot delete file using SharpSvn: {filepath} is not a working copy

I am unable to delete a file from SVN using SharpSvn.
Here is my code:
using (SvnClient client = new SvnClient())
{
// snip...
string filePath = "C:\\path\\to\\file.txt";
client.Delete(filePath, deleteArgs);
}
Here is the exception:
SharpSvn.SvnInvalidNodeKindException: ''C:\path\to\file.txt' is not a working copy'
I confirmed this filepath exists and is tied to SVN. What is the problem?
This question led me to the answer. I was using the incorrect casing in my filepath. Following the example above, maybe I tried to delete the file "C:\path\to\file.txt" but the actual path on disk was "C:\PATH\TO\file.txt". I fixed by using SvnTools.GetTruePath:
client.Delete(SvnTools.GetTruePath(filePath), deleteArgs);

Write text to file in Flutter(Dart)

I want to be able to create a new file and write a string into it. Examples that I can find all seems to pertain to writing to an existing file.
String fileName = 'myFile.txt';
String contents = 'hello';
void writeToFile(String fileName, String contents){
File outFile = File('content://com.android.providers.media.documents/document/document/document_root/' + fileName);
outFile.writeAsString(contents);
}
This results in the following error, as expected
Unhandled Exception: FileSystemException: Cannot open file, path = 'content://com.android.providers.media.documents/document/document/document_root/myFile.txt' (OS Error: No such file or directory, errno = 2)
How can I create a new file in which I can write my contents?
Are you sure that the path exists? writeAsString does create the file if it doesn't exists, but it doesn't create the full folder structure up to the file you're trying to write to. Also, you might not have the rights to write in the path you've specified.
Anyway, you'd better use this plugin to get the folders' path instead of hard-coding them.

Deploying app, troubles to reffer to datasets. Streamlit

Hello i have one more problem with deploying my app by Streamlit. It works localy but when I want to upload it on git hub it doesnt work..Have no idea whats wrong. It seems that there is problem with path to the file:
"File "/app/streamlit/bobrza.py", line 14, in <module>
bobrza_locations = pd.read_csv(location)"
Here is link to my github repo. Will be very very grateful for help. Thank in advance.
https://github.com/Bordonous/streamlit
The problem is you are hard coding the path of the bobrza1.csv and route.csv to the path on your computer so when running the code on a different environment the path in not legal.
The solution is to make location independent from running environment, for this we will use the following:
__file__ variable - the path to the current python module (the .py file).
os.path.dirname() - a function to get directory name from path.
os.path.abspath() - a function to get a normalized absolutized version of path.
os.path.join() - a function to join one or more path components.
Now you need to change your location and location2 variables in the code to the following:
# get the absolute path to the directory contain the .csv file
dir_name = os.path.abspath(os.path.dirname(__file__))
# join the bobrza1.csv to directory to get file path
location = os.path.join(dir_name, 'bobrza1.csv')
# join the route.csv to directory to get file path
location2 = os.path.join(dir_name, 'route.csv')
Resulting in an independent path of the bobrza1.csv and route.csv.

Renaming S3 files creates temp folders

I am trying to rename the S3 files which basically
copy to target + delete source
But in my case I am able to copy target but not able to delete source properly .
All directory structure remains same without any file ..
also it creates temp files in the main directory .
Do I have to explicitly delete it after renaming ?
Here is my code which renames the files
I have subfolders insode the folder.
val file = fs.globStatus(new Path(outputFileURL + "/*/*"))
for (urlStatus <- file) {
val DataPartitionName = urlStatus.getPath.toString.split("=")(1).split("\\/")(0).toString
val finalFileName = finalPrefix + DataPartitionName + "." + intFileCounter + "." + fileVersion + currentTime + fileExtention
val dest = new Path(mainFileURL + "/" + finalFileName)
fs.rename(urlStatus.getPath, dest)
intFileCounter += 1
}
If you check apache hadoop rename documentation, it says
The core operation of rename()—moving one entry in the filesystem to another ..
So its just moving the files and not renaming . More detail on the link above.
So I guess you will have to explicitly delete the folder name after renaming is complete
Instead of renaming the files only, you could rename the folder as well. That would not require you to explicitly delete the folder name.

Getting Meteor private folder path in Meteor Deploy Environment

I need to get the path of the file inside the private folder.
On my local machine I was able to get it by using the path "../../../../../", however, when I deployed to meteor server using meteor deploy, it doesn't work anymore. Also I tried to log the current directory using process.cwd() and got the following, which is different from the structure I got on my local machine:
/meteor/containers/3906c248-566e-61b7-4637-6fb724a33c16/bundle/programs/server
The directory logged from my local machine gives:
/Users/machineName/Documents/projectName/.meteor/local/build/programs/server
Note: I am using this path to setup https://www.npmjs.com/package/apn
You can use assets/app/ as the relative path. While this may not make sense on the first look Meteor re-arranges your /private directory to map to assets/app from the /programs/server directory. This is both in development and production.
Basically assume that private/ maps to assets/app/.
Call Assets.absoluteFilePath(assetPath) on one of the assets in the private folder, then chop of the name of the asset file from the string you get back, e.g., assuming you have a file called test.txt in the private folder:
var aFile = 'test.txt';// test.txt is in private folder
var aFilePath = Assets.absoluteFilePath(aFile);
var aFolder = aFilePath.substr(0, aFilePath.length - aFile.length);
console.log(aFolder);
https://docs.meteor.com/api/assets.html#Assets-absoluteFilePath