filestream

how to set a network path for filestream filegroup

。_饼干妹妹 提交于 2020-01-25 04:34:06
问题 How to configure a database so that filestream data is stored on a non local path? To enable filestream at db level I do first: ALTER DATABASE MyDatabase ADD FILEGROUP FileStreamFileGroup CONTAINS FILESTREAM; GO Then: ALTER DATABASE MyDatabase ADD FILE ( NAME = MyDatabaseFileStreamFile, FILENAME = 'c:\Test') TO FILEGROUP FileStreamFileGroup ; GO Now instead of c:\Test I want to set a network path, for example: \\Fileserver\Test but this doesn't work: ALTER DATABASE MyDatabase ADD FILE ( NAME

IOException at java.io.File.createNewFile();

丶灬走出姿态 提交于 2020-01-24 14:25:28
问题 I do have some code for serialization which does not work. I have tried to insert both CanRead() and CanWrite() in if-statements which showed they did not have permissions to read and write. I have also tried to insert 'java.io.File.setReadable' and 'java.io.File.setWriteable to true but it still throws the error. The code is as following: public static void save(Object obj, String filename) throws FileNotFoundException, IOException { File f = new File("c:/DatoChecker/" + filename); File dir

System.IO.IOException: Sharing violation on path in C#

大憨熊 提交于 2020-01-22 02:21:05
问题 I have used below code to save the file in xamarin forms ios but give me System.IO.IOException: Sharing violation please help me. FileStream fileStream = File.Open(pdfPath, FileMode.Create); stream.Position = 0; stream.CopyTo(fileStream); fileStream.Flush(); fileStream.Close(); 回答1: Have you checked that your app has permission for accessing files on the system? Also i would to a check to see if the files exist before opening it with File.Exists(); . Also there are better ways of reading and

Trying to stream a PDF file with asp.net is producing a “damaged file”

北慕城南 提交于 2020-01-20 04:10:09
问题 In one of my asp.net web applications I need to hide the location of a pdf file being served to the users. Thus, I am writing a method that retrieves its binary content from its location on a CMS system and then flushes a byte array to the web user. I'm getting, unfortunately, an error when downloading the stream: "Could not open the file because it is damadged" (or something similar to that, when opening the file in adobe reader). Question 1: what am I doing wrong? Question 2: can I download

FileStream seems to find an unexisting file

心已入冬 提交于 2020-01-17 04:43:05
问题 I have this code: public static string GetUserEmail() { string path = Application.StartupPath + "\\mail.txt"; MessageBox.Show(path); string adres = String.Empty; if (File.Exists(path)) { using (StreamReader sr = new StreamReader(path)) { adres = sr.ReadLine(); } } else { using (FileStream fs = File.Create(path)) { using (StreamReader sr = new StreamReader(path)) { adres = sr.ReadLine(); } } } MessageBox.Show(adres); return adres; } I checked the ApplicationPath with the MessageBox.Show(); as

how to delete required string from csv file

☆樱花仙子☆ 提交于 2020-01-16 19:46:24
问题 hi all try to realize deleting line in some csv file; example of file: 24 august 2013 г.,,14:00,00:00,; 24 august 2013 г.,,14:00,00:00,; 24 august 2013 г.,2342,14:00,00:00,23424; 24 august 2013 г.,2342,14:00,19:00,23424; criteria - 24 august 2013 г.,2342 result must be like 24 august 2013 г.,,14:00,00:00,; 24 august 2013 г.,,14:00,00:00,; my idea open file - FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite); StreamReader sr = new StreamReader(fs); get all data in

Why would I get, “The remote server returned an error: (400) Bad Request” with this code?

回眸只為那壹抹淺笑 提交于 2020-01-16 17:34:09
问题 I was first getting "Unable to connect to the remote server" but then remembered that I couldn't use "localhost" from a handheld device. I swapped that out with the name of the machine like so: String uri = String.Format(@"http://PLATYPUS:21608/api/inventory/sendXML/woodrow/gus/{0}", fileName); //I reckon I could also use the IP address in place of the machine name, but probably would make no difference ...and now I get, " The remote server returned an error: (400) Bad Request " The same

Is FileStream the safest way to copy a file vs. File.Copy?

安稳与你 提交于 2020-01-16 01:17:09
问题 I would like to copy the file from source to destination directory. I heard that it is best to do this with a FileStream in case it gets modified later / accessed later. I am using C# 2.0 and .NET 2.x. I don't need to determine if the file is open or not or read/write or not. I just need to copy it as is, I have already determined that the file has stopped growing (check every 4 seconds) so that is 'good enough' in my situation. So should I use MemoryStream or FileStream or File.Copy(..) and

Sql 2008 Filestream with NHibernate

我的未来我决定 提交于 2020-01-14 18:55:51
问题 I am attempting to use Filestream in sql server 2008 to store user uploaded images. My problem is that NHibernate will not error, but it also will not save the data into the database. No record is created. The Image class below is a custom class (not to be confused with System.Drawing.Image) public class ImageMap : ClassMap<Image> { public ImageMap() { WithTable("Images"); Id(x => x.ImageId).GeneratedBy.GuidComb().WithUnsavedValue(Guid.Empty); Map(x => x.ImageData); Map(x => x.Extension);

Sql 2008 Filestream with NHibernate

╄→尐↘猪︶ㄣ 提交于 2020-01-14 18:55:19
问题 I am attempting to use Filestream in sql server 2008 to store user uploaded images. My problem is that NHibernate will not error, but it also will not save the data into the database. No record is created. The Image class below is a custom class (not to be confused with System.Drawing.Image) public class ImageMap : ClassMap<Image> { public ImageMap() { WithTable("Images"); Id(x => x.ImageId).GeneratedBy.GuidComb().WithUnsavedValue(Guid.Empty); Map(x => x.ImageData); Map(x => x.Extension);