filestream

Physical location of FILESTREAM data

£可爱£侵袭症+ 提交于 2019-12-01 01:30:18
How could I know the physical location (so I can see it in Windows Explorer) path of a FILESTREAM data that I've just inserted into DB? There is one option for this: method PhysicalPathName(). If you are on SQL Server 2012 or upper now, this code will work for you: SELECT stream.PhysicalPathName() AS 'Path' FROM Media OPTION (QUERYTRACEON 5556) For SQL Server 2008/2008 R2 you will need to enable trace flag 5556 for the whole instance: DBCC TRACEON (5556, -1) GO or for the particular connection in which you are calling PhysicalPathName() method: DBCC TRACEON (5556, -1) GO I know this is an

Redirect writes to a file to a stream C#

会有一股神秘感。 提交于 2019-12-01 00:58:43
I wanted to ask if it is possible to redirect writes to a specific file, to a memory stream in my application so I can immediately read it. If it is possible please explain how to do so. Thanks. Make sure your application works with Stream , and then you can use the MemoryStream concrete implementation to accomplish streaming without a file. What you need is a stream which writes to a file as well as to another stream which you are watching - a stream splitter, commonly known in the Unix world as tee . For .NET you can use this implementation of a stream splitter. Pass it a FileStream (so that

Python command line 'file input stream'

谁说胖子不能爱 提交于 2019-12-01 00:18:28
问题 I'm fairly new to python coming from C/C++, I was wondering how I would get my 'main.py' to reconize/use the imput given from a bash shell as: python main.py < text.txt (the file is in plain text) 回答1: I would use argparse to create an option parser that accepts a file path and opens it. import argparse def main(): parser = argparse.ArgumentParser() parser.add_argument('infile', type='open') args = parser.parse_args() for line in args.infile: print line if __name__ == '__main__': main() If

stream.CopyTo - file empty. asp.net

拜拜、爱过 提交于 2019-11-30 21:31:20
问题 I'm saving an uploaded image using this code: using (var fileStream = File.Create(savePath)) { stream.CopyTo(fileStream); } When the image is saved to its destination folder, it's empty, 0 kb. What could possible be wrong here? I've checked the stream.Length before copying and its not empty. 回答1: There is nothing wrong with your code. The fact you say "I've checked the stream.Length before copying and its not empty" makes me wonder about the stream position before copying. If you've already

Sending File in Chunks to HttpHandler

二次信任 提交于 2019-11-30 21:31:17
I'm trying to send a file in chunks to an HttpHandler but when I receive the request in the HttpContext, the inputStream is empty. So a: while sending I'm not sure if my HttpWebRequest is valid and b: while receiving I'm not sure how to retrieve the stream in the HttpContext Any help greatly appreciated! This how I make my request from client code: private void Post(byte[] bytes) { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://localhost:2977/Upload"); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.SendChunked = true; req.Timeout = 400000;

Physical location of FILESTREAM data

只谈情不闲聊 提交于 2019-11-30 19:47:48
问题 How could I know the physical location (so I can see it in Windows Explorer) path of a FILESTREAM data that I've just inserted into DB? 回答1: There is one option for this: method PhysicalPathName(). If you are on SQL Server 2012 or upper now, this code will work for you: SELECT stream.PhysicalPathName() AS 'Path' FROM Media OPTION (QUERYTRACEON 5556) For SQL Server 2008/2008 R2 you will need to enable trace flag 5556 for the whole instance: DBCC TRACEON (5556, -1) GO or for the particular

JPEG data-stream to TImage

此生再无相见时 提交于 2019-11-30 19:28:23
I have some image-files stored into one file (some kind of archive). That file looks like this: Well, it's separated into two segments - header and data-segment. Header (green) contains various info, such as album name, location, date/time, description, number of photos in the album, etc. Data segment (blue & orange) has simple structure and it contains N x JPEG photo. I can extract that "imagedata" segment into new TMemoryStream object and now I want to show it using TImage. I can use SaveAsFile method of TMemoryStream, set some temporary file-name, load that file from TImage, and later,

Easiest way to read text file which is locked by another application

≯℡__Kan透↙ 提交于 2019-11-30 17:11:23
I've been using File.ReadAllText to grab some csv, but every time I forget to close the file in Excel, the application throws an exception because it can't get access to the file. (Seems crazy to me, I mean the READ in ReadAllText seems pretty clear) I know that there is File.Open with all the bells and whistles, but is there an 'intermediate' method which doesn't involve messing around with buffers and char arrays? Yes, I'm lazy, so vote me down, just give me the answer first :) Noldorin I think you just want the following: using (var fileStream = new FileStream("foo.bar", FileMode.Open,

how do I zip multiple files using GZipStream in c#

北战南征 提交于 2019-11-30 16:09:44
I have created multiple csv files using datatable and want to zip all those file into one single zip file. Which is i'm doing all at dynamically. I tried following code List<string> filestream = GenerateCSVfiles(dataSets); //Generate CSV files public List<string> GenerateCSVfiles(List<DataSet> dataSets) { List<string> filestream = new List<string>(); StringBuilder result = null; foreach (DataSet dataSet in dataSets) { result = new StringBuilder(); System.Data.DataTable dataTable = dataSet.Tables[0]; foreach (DataColumn colm in dataTable.Columns) { result.Append(colm.ColumnName+","); } result

Load binary file using fstream

混江龙づ霸主 提交于 2019-11-30 15:59:18
I'm trying to load binary file using fstream in the following way: #include <iostream> #include <fstream> #include <iterator> #include <vector> using namespace std; int main() { basic_fstream<uint32_t> file( "somefile.dat", ios::in|ios::binary ); vector<uint32_t> buffer; buffer.assign( istream_iterator<uint32_t, uint32_t>( file ), istream_iterator<uint32_t, uint32_t>() ); cout << buffer.size() << endl; return 0; } But it doesn't work. In Ubuntu it crashed with std::bad_cast exception. In MSVC++ 2008 it just prints 0. I know that I could use file.read to load file, but I want to use iterator