I have created a pdf file using c# code and now i want to save created pdf file into my local machine drive "E" but an error shown to me that "Access to the path 'E:\My Projects' is denied."...
here is the code to save pdf file
FileStream fileStream = new FileStream(#"E:\My Projects", FileMode.OpenOrCreate,
FileAccess.ReadWrite, FileShare.None);
Any one please help me out....
Assuming you have
path a string with the full qualified name and
pdf a byte[] of the generated pdf,
then just do:
File.WriteAllBytes(path, pdf);
See http://msdn.microsoft.com/en-us/library/system.io.file.writeallbytes.aspx
Related
I am trying to upload some files to dropbox using their java API (version 2-beta-4), but some of these files have the same name.
What I would like to know is: What is the reason for I send a file (for instance "file.txt") to dropbox, this file is uploaded, but if I send another file with the same name (file.txt) dropbox overwrite the old file with this new one instead of renaming it to "file (1).txt", even I am setting autorename true and the WriteMode to add?
Code:
DbxRequestConfig config = new DbxRequestConfig("sample", "pt_BR");
String acessToken = "...";
client = new DbxClientV2(config, accessToken);
InputStream input = new ByteArrayInputStream(file.getBytes());
FileMetadata file = client.files.uploadBuilder(path).mode(WriteMode.add).autorename(true)
.mute(true).run(input);
Thanks.
WriteMode.add is what's causing this behavior. "Add" means "Add a new file with this name," so it never overwrites an existing file. If you want to overwrite the existing file, use WriteMode.overwrite.
(Also, isn't it WriteMode.add() and WriteMode.overwrite()? I thought those were methods.)
hello evryone
wanna load file from a specific path writen in an edit box named by 'Load_text', i got the path from the edit box using :
pth=get(handles.Load_text,'string');
then i used 'dir' as follow:
S=dir(fullfile([pth '*.bmp']));
that what cause me an errur . so any ideas ?
If you want to load a file then why you are using dir?
Since you have the file's name, then you can create the fullpath as you do with the fullpath method and check its existence with exists.
If the file exists, then you can load it with all available methods from MATLAB.
Keep in mind that this means that the file is in the same directory as your GUI files. If it is in another then you will have to add it in the fullpath call.
fullpath online doc: http://www.mathworks.com/help/matlab/ref/fullfile.html
exists online doc: http://www.mathworks.com/help/matlab/ref/exist.html
string filePath = #"C:\test.pdf";
CloudBlockBlob blockBlob = container.GetBlockBlobReference("DxRecordForm");
FileStream localDirDxRecordForm = File.Create(filePath);
localDirDxRecordForm.Close();
dxCodeReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, filePath);
using (var fileStream = System.IO.File.OpenRead(filePath))
{
blockBlob.UploadFromStream(fileStream);
}
I am exporting a crystal report into pdf format and then saving the pdf in azure storage container. In above code dxCodereport is an instance of crystal report. When I view my storage container, I see the block blob named DxRecordForm. When I click that, I am also able to see the pdf version of my crystal report.
I am not sure why I don't see the file Test.pdf inside my container. I just see the block blob with content-type application/octet-stream.
Your code snippet above uploads the file C:\test.pdf to a block blob named DxRecordForm. This would not result in creating a blob named test.pdf. If you would like to upload it a blob named test.pdf, please use "test.pdf" when getting a block blob reference.
Is there any sample code to copy content of a .docx file to another .docx file and retain the style of text using Apache POI? Please help.
XWPFDocument sourceDoc = new XWPFDocument(new FileInputStream("C:\\desktop\\sample.docx"));
XWPFDocument destDoc = sourceDoc;
Now using the above code watever is in sourceDoc is copied to destDoc with the same format.
In the above code,sourceDoc is used as a template of sorts.
I am using wicket framework, and I have made a zip file by Java code, I want to have a link to download it, I don't know if it is possible or I should make the zip file by wicket (but not Java) and then have a link to download.
Take a look at ZipResourceStream. With this class you can generate zip contents of a directory on the fly, and use a org.apache.wicket.markup.html.link.ResourceLink with ResourceStreamResource to link to it.
File file = new File(path);
IResourceStream resStream = new ZipResourceStream(file);
ResourceStreamResource resource = new ResourceStreamResource(resStream);
ResourceLink link = new ResourceLink("link", resource);
add(link);
Alternatively, if you prefer to zip the file with another tool, you can use DownloadLink:
File zipFile = generateZipFile();
IModel fileModel = new Model(zipFile);
add(new DownloadLink("dllink", fileModel);
If you prefer to generate the File on the fly in the Link's onClick, take a look at this question: How to use Wicket's DownloadLink with a file generated on the fly?