golang: Monitor (and read) files open for writing - file

I have some .log files and want to monitor if any data is appended to any of them to collect that data into a DB.
How do I open an opened-for-writing file and how do I monitor for new lines/changes?
Thank you.

Related

How to save multiple files in Android

Here I want to save multiple files in android(internal or external storage). I have used a way to save file. It saves only the last file. Not the all files. Can you please check this and if there are any changes please comment here

How to extract one file from Zipped file

The scenario is that my data file is located in remote machine, the file is a zip file and its size is very big. Now I want to extract a target file according to the file name, but I don't want to download the whole file from the remote machine. Could any method help to identify the target file quickly and then download part of the data from the remote file? Btw, the development language is C#.
There is no way for local code to unzip a remote file without completely downloading it. If you want to minimize the amount of data transferred, you need some service running on the remote machine doing the extraction part and then transferring only your desired file.

Where to store temporary files using a windows forms application

I have an application that downloads a file from FTP, reads the file, then deletes it (i download a temporary file because the stream gets disposed before i read the end of the data and i get an exception) and I was wondering what is the programming convention for storing temporary files? Basically right now I just download the file to the desktop directory (testing phase still) so it pops up on the desktop for a second while it's read then deleted.
Use System.IO.Path.GetTempFileName() to get a randomly named file in the system's temp directory. Download to there.
Be sure to use System.IO.File.Delete() when you're done with it!
https://msdn.microsoft.com/en-us/library/system.io.path.gettempfilename%28v=vs.110%29.aspx

How to read a Microsoft Excel file which is already opened

I want to develop an application which reads data from an MS excel file which is opened.
I want to develop this application because the data is updated for every one minute in the cells present in it and i cant see it again if i want to see. so i want to read the file data and save it in a text file or an ms access file.
I know how to save it but i dont know how to read the ms excel file which is opened.
There would be a great appreciation if someone could help me.
Thanks In Advance.
If I understand your query, you'll need to open the file in read only mode to prevent any access violations from occuring.
(eg. Your app saves some new data and then the open file is saved, removing your saved data)
If you are opening it in read-only, you'll need a refresh timer that will check for revisions of the file. It would only update if the Excel file is saved as you would not be able to access the memory location of an unsaved file.
Perhaps saving your data as .CSV will be easiest to read in to your app. Excel will allow you to save as this type and it is easy to read in C#, using a normal file stream.
Hope this helps.

Upload changes made to the file (FTP)

I'm making some kind of FTP Uploader Client. I can upload files, but I don't know how to upload changes made to the file. What I mean when saying changes is not that file was renamed, but when its content has changed. For example I have a *.rar file (large enough) with some files in it. When I add some new file, I don't want the whole *.rar to be uploaded, just the part that changed. I know about WebRequestMethods.Ftp.AppendFile but it appends only at the end of file, and what if changes where applied in the middle? I'll get a junk file...
I've read about "binary diff" & seen a couple of client that make changes directly on the server (FileZilla, Direct FTP, ALFTP)
Actually if files in your rar archive are changed - you should rebuild and re upload whole archive.
FTP share not saving history of what files changed, or renamed. So, the only solution is:
Save list of files in some kind of xml on client application.
When you retrieve list of files from ftp - compare if with list of files in your history xml.
These two steps won't help you to find what files were renamed, but will provide you with information of what files removed or added.
Comparing if file were changed can be done by saving in your history file size of them. If you need more precise check you can generate CRC for files:
http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net
but generating of the crc is a very long task.

Resources