filestream

SQL Server Integrated Security

余生颓废 提交于 2019-12-02 10:02:14
I've been searching hard to get my head around security related issues in a SQL Server. We're developing a .NET application that targets SQL Server 2008 and we want to use FileStream. Now I've found out that SQL Server only allows FileStream through the Win32 API if you use Integrated Security. The problem is that we have around 80% of our application finished, but it is entirely based on SQL Authentication. So we are doing INSERT's straight form our application and are not using Stored Procedures for every CRUD operation. This is relatively safe because I can store the the SQL username and

Write chinese characters from one file to another

谁都会走 提交于 2019-12-02 09:07:46
问题 I have a file with Chinese characters text inside, I want to copy those text over to another file. But the file output messes with the chinese characters. Notice that in my code I am using "UTF8" as my encoding already: BufferedReader br = new BufferedReader(new FileReader(inputXml)); StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append("\n"); line = br.readLine(); } String everythingUpdate = sb.toString(); Writer out = new

Garbage Value in File after write

帅比萌擦擦* 提交于 2019-12-02 08:39:23
I am making a log function which stores in a file. int log_func(char* msg) { int log_fd=0; ssize_t write_ret=0; int close_logfile_ret=0; time_t result; char error_msg[MAX_LOG_MSG_LEN]={' '}; log_fd = open("/home/pi/log_client.txt", O_CREAT|O_APPEND|O_WRONLY); if(log_fd==-1) { printf("log failed !!----file open"); exit(1); } result = time(NULL); snprintf(error_msg,MAX_LOG_MSG_LEN,"DALI_Server:%s:%s",asctime(localtime(&result)),msg); write_ret = write(log_fd,error_msg,sizeof(error_msg)); if(write_ret == -1) { printf("log failed !!---- write"); exit(1); } close_logfile_ret = close(log_fd); if

BufferedReader.readLine() do not read and hang the system(wait) [closed]

别来无恙 提交于 2019-12-02 08:23:02
BufferedReader.readLine() do not read and hang the system(wait) . InputStream istrm = runtimeProcess.getInputStream(); InputStreamReader istrmrdr = new InputStreamReader(istrm); BufferedReader buffrdr = new BufferedReader(istrmrdr); System.out.println("4"); String data; String st; System.out.println("4a"); while (!(st=buffrdr.readLine()).isEmpty()) { System.out.println("5 in loop"); } You need to continually read from the processes input stream to ensure that it doesn't block. Read this : http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html The point is this line while (!(st

Reading first N bytes of a file as an InputStream in Java?

左心房为你撑大大i 提交于 2019-12-02 06:14:09
For the life of me, I haven't been able to find a question that matches what I'm trying to do, so I'll explain what my use-case is here. If you know of a topic that already covers the answer to this, please feel free to direct me to that one. :) I have a piece of code that uploads a file to Amazon S3 periodically (every 20 seconds). The file is a log file being written by another process, so this function is effectively a means of tailing the log so that someone can read its contents in semi-real-time without having to have direct access to the machine that the log resides on. Up until

as3 URLRequest and file stream saving xml data - Error #3013: File or directory is in use

假如想象 提交于 2019-12-02 06:09:10
My end goal is to open an xml file, change data and save it. I am opening it with a URLRequest. I am able to change the xml, however, MY ISSUE IS: When I try to open it with a stream to save the file then it says: Error: Error #3013: File or directory is in use. I suppose I could open it with the same stream but then I don't know how to get the xml vars like I do in my script when I am using the URLRequest. So I either need to a) close the xml file so I can open it with a stream or b) open the xml with a stream and some how get the vars I need and manipulate them for saving. There may be a c)

What does a hash do to a variable in VB?

五迷三道 提交于 2019-12-02 04:54:45
I have to refactor a VB6 program to C# and am stuck at understanding the following lines: Set myFileSystemObject = New FileSystemObject Set myTextStream = myFileSystemObject.OpenTextFile("myTextFile.txt") Open sPrinterPort For Output As iFileNumber Print #iFileNumber, myTextStream.ReadAll Close #iFileNumber I do know what's generally happening, but as I'm not used to the VB syntax, I'd like to know exactly what Print #iFileNumber, myTextStream.ReadAll does. And more specifically, what the # in front of iFileNumber does. Why is it there? Wouldn't the variable itself suffice to print on the

Write chinese characters from one file to another

倾然丶 夕夏残阳落幕 提交于 2019-12-02 04:44:56
I have a file with Chinese characters text inside, I want to copy those text over to another file. But the file output messes with the chinese characters. Notice that in my code I am using "UTF8" as my encoding already: BufferedReader br = new BufferedReader(new FileReader(inputXml)); StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); sb.append("\n"); line = br.readLine(); } String everythingUpdate = sb.toString(); Writer out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(outputXml), "UTF8")); out.write(""); out.write

Removing Characters from a File

感情迁移 提交于 2019-12-02 04:38:11
问题 How can arbitrary characters be removed (not replaced by something) in a file? #include <fstream> int main() { std::fstream FileStream("MyFile.txt", ios_base::in | ios_base::out | ios_base::binary); // For the sake of argument, MyFile.txt already has stuff in it. FileStream.seekg(5); FileStream.remove(); // Something like this. } 回答1: You have two options: Read the entire file in the memory, then save it to the file excluding unwanted parts. Copy the source file to newly created file

The bytes my server program receives is incomplete. Why? I'm using C# .net sockets

我的梦境 提交于 2019-12-02 04:21:07
This doesn't always happen. But it happens more often than receiving the bytes completely. This is how my client prog sends bytes to my server prog: public void sendBytes() { FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); TcpClient cli = tcpServer; //tcpServer is a global TcpClient variable I use to connect to the server. NetworkStream ns = cli.GetStream(); CopyStreamToStream(fs, ns, null); ns.Flush(); } public static void CopyStreamToStream(Stream source, Stream destination, Action<Stream, Stream, Exception> completed) { byte[] buffer = new byte