i need to access folder in project .I have used Directory.CurrentDirectory and it is not working is there a way to access folders in Folder structure
r u trying to access with in the project folder meanz local folder???
if u trying that so u can use this one in my case m creating folder u can change it
StorageFolder folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Folder Name", CreationCollisionOption.OpenIfExists);
and also u can access folder with given uri path like this, in my case m pick images from local folder within the project..
private String imagePath = null;
ImageSource image = new BitmapImage(new Uri(new Uri("ms-appdata:///local/Folder Name/"), this.imagePath));
Related
I have a Google Sheet with a list of URLs for files - roughly 900 entries, maybe 95% PDFs with a few .docs and .docxs in there as well.
I would like to upload every file to a Google Drive folder - ideally a shared folder within my employer's workspace - retaining the filename, which I also have in the sheet.
I have found some near-answers on here, but they use deprecated Google Scripts methods.
For example:
var urlOfThePdf = 'http://www.fostexinternational.com/docs/tech_support/pdfs/280_owners_manual.pdf';// an example of online pdf file
var folderName = 'GAS';// an example of folder name
function saveInDriveFolder(){
var folder = DocsList.getFolder(folderName);// get the folde
var file = UrlFetchApp.fetch(urlOfThePdf); // get the file content as blob
folder.createFile(file);//create the file directly in the folder
}
fails at getFileFromURL.
Any suggestions gratefully received.
This piece of code will save the the pdf into the desired folder:
var urlOfThePdf = '';// an example of online pdf file
var folderName = '';// an example of folder name
function saveInDriveFolder(){
var folders = DriveApp.getFoldersByName(folderName);
var file = UrlFetchApp.fetch(urlOfThePdf);
while (folders.hasNext()) {
var folder = folders.next();
folder.createFile(file);
}
}
It uses the DriveApp.getFoldersByName() method to fetch all folders with that name, UrlFetchApp.fetch() to fetch the pdf and folder.createFile() to save the pdf in the folder.
Note that DriveApp.getFoldersByName() fetches a folder iterator (all the folders in your Drive with that name). In this code, I am iterating through all the folders with that name and saving the pdf in all of them.
I would recommend using Drive.getFolderById() and supplying the id of your desired folder (can be extracted from the url). Using this, you will only save the pdf in one folder and you will not have to iterate though the folders in the code (the whole while loop can be replace by: folder.createFile(file);).
Is it possible to access publicly shared dropbox folder or file programmatically with out using app key or app secret,just by using url
If it helps someone :
Option to share DropBox folders and access files via URLs by names - with NO NEED TO Share each file
e.g.
STEP 1 : Create a new folder for your images ( or any other files ) in your PUBLIC Dropbox folder
1. Create a folder in PUBLIC folder (e.g. MyTestFolder)
2. Put an image file in this folder (e.g Grupya_whatsApp_logo.jpg)
-
STEP 2 : Get the USERID of your public Dropbox folder ( it is the same USERID also for subfolder within PUBLIC )
3. Copy public link of Image created in step 2 (e.g Grupya_whatsApp_logo.jpg)
4. Please note syntax will be something like :
https://u17835471.dl.dropboxusercontent.com/u/17845471/MyTestFolder/Grupya_whatsApp_logo.jpg
5. You May change URL reference to somthing shorter :
https://dl.dropbox.com/u/17845471/MyTestFolder/Grupya_whatsApp_logo.jpg
-
STEP 3 : Now - You can create any sub folder under PUBLIC folder and reference to it by using Filenames that are in this directory, directly
https://dl.dropbox.com/u/17845471/MyTestFolder/Grupya_whatsApp_logo.jpg
https://dl.dropbox.com/u/17845471/MyTestFolder/BFly.jpg
If you're referring to a Dropbox shared link for the folder, you can download all of the file content as shown here:
https://www.dropbox.com/help/201
For anything else, you'd need to use the API, which does require an API app, e.g.:
https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_metadata
https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file
I have a script that merger some google docs, but it create the file in the root dir, i want the script to add it into a existing folder.
Code
Sorry im new to this..How do i do this?
Thanks
I believe you want to achieve this using Apps Script.
You could use Apps script's DriveApp.getFolderById() method to get the required folder. Also DocumentApp.create() method to create a document.
Please find the working example to create a file in specific Drive folder:
function createDoc()
{
var targetFolder = DriveApp.getFolderById(folderID);
var newDoc = DocumentApp.create('My file1');
var file = DriveApp.getFileById(newDoc.getId());
targetFolder.addFile(file);
}
Tried and tested the code.
If you want to create a Spreadsheet file, you just use SpreadsheetApp instead. Hope that helps!
I am trying to upload a file in Zend framework. I have following code in my form:
$this->addElementPrefixPath('App', 'App/');
$this->setName('upload');
$this->setAttrib('enctype', 'multipart/form-data');
$description = new Zend_Form_Element_Text('description');
$description->setLabel('Description')
->setRequired(true)
->addValidator('NotEmpty');
$file = new Zend_Form_Element_File('file');
$path="/images";
$file->setDestination($path)
->setLabel('File')
->setRequired(true)
->addValidator('NotEmpty');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Upload');
$this->addElements(array($description, $file, $submit));
I am using netbeans and I have one folder named images under public folder. I want that all files are uploaded into images folder but when I run the project it gives the error as
The given destination is not a directory or does not exist
If I give the full path as C:\Users\398853\Documents\NetBeansProjects\ZendWithFileUpload\public\images then it runs fine and the file gets uploaded into images folder. But when I give $path='/images' It says above error'Why? What should be the path given?Thanks.
In SetDestination should be setted absolute path to desitnation folder (/var/www/... or c:/webserver/... in case when you win-user).
But good practice is to get absolute path with functions getcwd() or realpath(dirname(FILE)).
So, at first you shoud define constant (for example with name PUBLIC_PATH) in index.php file (usually situated in public-folder).
defined('PUBLIC_PATH')
|| define('PUBLIC_PATH', realpath(dirname(__FILE__)));
This way you can use variable PUBLIC_PATH instead of writting string "/var/www/..." as prefix to your real path to upload folder.
So, if your "images" folder situated in "public" folder, you should user such construction:
$file->setDestination(PUBLIC_PATH . '/images');
This code also will work after upload project from localhost to webserver.
add config to module.config.php
return array (
....
//other settings
'module_config' => array(
'upload_location' => __DIR__.'/../../../data/uploads'
)
);
add controller
public function getFileUploadLocation() {
$config = $this->getServiceLocator()->get('config');
return $config['module_config']['upload_location'];
}
and use
....
$uploadPath = $this->getFileUploadLocation();
$adapter->setDestination($uploadPath);
....
In your bootstrap code, you need to set your application's root folder.
Whenever you want to get the path of a subfolder in your application folder (eg. images in your scenario), you need to use this variable and append your folder name.
If your bootstrap code is in the Application folder which is under the public root folder,
Zend_Registry::set('APP_ROOT', dirname(dirname(__FILE__)));
In other places of your application, when you want get a folder path, like you want to get the image folder path under the public folder, u need to use,
Zend_Registry::get('APP_ROOT') . "/images";
I am unable to add a new file using tfs sdk:
int a = workspace.PendAdd(path,recursive );
What is this argument "Path"? path of file where to add or from where to add?
or before using this method v have to copy the new file in this folder?
If you are trying to add a folder, the directory has to exist first. If you are trying to add a file, the file has to exist first. After that you can run, for example:
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("http://WhateverServerUrl");
VersionControlServer VsServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
Workspace ws = VsServer.GetWorkspace("WORKSPACE_NAME", "WORKSPACE_OWNER");
ws.PendAdd(#"C:\MyFolder", true);
Keep in mind that the identity exec this command needs to have permissions to create the folder if in fact you are creating a folder.
So to create a folder though of course you would have to add code to do assuming it doesn't already exist:
System.IO.Directory.CreateDirectory(#"C:\MyFolder");