filestream

What are user permission with impersonation to write file at server path?

[亡魂溺海] 提交于 2019-12-08 09:12:17
问题 I used the example below but i have still have exception : System.Security.Permissions.SecurityPermission Here below is presented diagnostic info for technical support personel: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib Admin said the user credential has full permission to read and write IntPtr userToken = IntPtr.Zero; bool success = External.LogonUser( "userID", "domain.com", "MyPassword", (int) AdvApi32Utility.LogonType.LOGON32_LOGON

Consume FileStream from WCT Restful service

妖精的绣舞 提交于 2019-12-08 04:55:06
问题 I have created a WCF Restful service, with the following code: Interface: [ServiceContract] public interface ISIGService { [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "GetMultimedia/{id}")] Stream GetMultimedia(string id); } The code that implements this Service: public Stream GetMultimedia(string id) { string filePath = MultimediaBLL.GetFilePath(int.Parse(id)); if (string.IsNullOrEmpty(filePath))

The process cannot access the file 'C:\inetpub\wwwroot\MyApp\5-23-2011.log' because it is being used by another process

北战南征 提交于 2019-12-08 04:37:31
问题 I have a singleton logger which is used inside an ASP.NET application. Sometimes I get The process cannot access the file error on this line: StreamWriter sw = new StreamWriter("Path to log file", true); I checked file handle by Process Explorer and w3wp.exe owns the handle so it seems different threads from the same process caused the problem. I have used a lock around the above code, but still I get the error. How can I make sure all threads can use the same stream safely? 回答1: Don't open

How to manage huge amount of data using filestream since only local paths are supported for data storage?

一曲冷凌霜 提交于 2019-12-07 23:57:44
问题 As pointed out in this question when using filestream with sql server 2008 the data must be stored locally. This means that I cannot use \\FILESERVER\FileStreamData\MyDatabase for Filestream filegroup path. So if I need to use filesrteam and have lots of data, is buying a very large hard drive the only solution (this could be quite limiting in many scenarios)? It is not possible to use a NAS? Typically one installs SQL Server on a perofrming machine but keeps the large documents in a NAS or

Seeking and writing files bigger than 2GB in C#

我与影子孤独终老i 提交于 2019-12-07 15:57:27
问题 In C#, the FileStream 's methods Read/Write/Seek take integer in parameter. In a previous post , I have seen a good solution to read/write files that are bigger than the virtual memory allocated to a process. This solution works if you want to write the data from the beginning to the end. But in my case, the chunks of data I am receiving are in no particular order. I have a code that works for files smaller than 2GB : private void WriteChunk(byte[] data, int position, int chunkSize, int count

Reading large files in bytes

跟風遠走 提交于 2019-12-07 15:00:40
问题 EDIT: As per the suggestion, I have started to implement the following: private string Reading (string filePath) { byte[] buffer = new byte[100000]; FileStream strm = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, 1024, FileOptions.Asynchronous); // Make the asynchronous call IAsyncResult result = strm.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(CompleteRead), strm); } private void CompleteRead(IAsyncResult result) { FileStream strm = (FileStream)result

Processing C# filestream input in WHILE loop causing execution time error

眉间皱痕 提交于 2019-12-07 13:23:35
问题 I have a C# console app that I'm trying to create that processes all the files in a given directory and writes output to another given directory. I want to process the input files X bytes at a time. namespace FileConverter { class Program { static void Main(string[] args) { string srcFolder = args[0]; string destFolder = args[1]; string[] srcFiles = Directory.GetFiles(srcFolder); for (int s = 0; s < srcFiles.Length; s++) { byte[] fileBuffer; int numBytesRead = 0; int readBuffer = 10000;

How do I zip files in Xamarin for Android?

筅森魡賤 提交于 2019-12-07 12:02:39
问题 I have a function that creates a zip file a string array of files passed. The function does succeed in creating the zip file and the zip entry files inside it, but these zip entry files are empty. I've tried a couple of different methods - the function code below is the closest I've gotten to something working: public static bool ZipFile(string[] arrFiles, string sZipToDirectory, string sZipFileName) { if (Directory.Exists(sZipToDirectory)) { FileStream fNewZipFileStream; ZipOutputStream zos;

Consume FileStream from WCT Restful service

那年仲夏 提交于 2019-12-07 09:44:28
I have created a WCF Restful service, with the following code: Interface: [ServiceContract] public interface ISIGService { [OperationContract] [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "GetMultimedia/{id}")] Stream GetMultimedia(string id); } The code that implements this Service: public Stream GetMultimedia(string id) { string filePath = MultimediaBLL.GetFilePath(int.Parse(id)); if (string.IsNullOrEmpty(filePath)) return null; try { FileStream multimediaFileStream = File.OpenRead(filePath); return multimediaFileStream

c copy files in reverse order using lseek

北战南征 提交于 2019-12-07 06:27:19
问题 I've got how to copy one file to another from start, but how could i modify the programme to copy it in reverse order? Source file should have read access and destination file read write execute. I have to use file control libraries. for example FILE A File B should be |---------| |----------| |ABCDEF | |FEDCBA | |---------| |----------| ** * ** * ** * ** * ** * ** * ** * UPDATE * ** * ** * ** * Thank you, MikeNakis for hints and suggestions ,Sangeeth for your code I've reworked the code and