C# progress bar and EdtFTPnet Bytestransferred event - c#

Hello peeps at Stack Overflow, I have a problem that I've been trying to solve since a couple of days. I have a problem in which I want to display via a progress bar, the bytes transferred from the bytes total of a remote file over FTP.
On the documentation it has been written how to use the ftp events from the library using FTPConnection as an exemple, but i cant get it to work with the BytesTransferred event. I define the method into my code but where exactly or how exactly am i suppose to use it with the progressbar, or with the backgroundworker.reportProgress() method?
If anyone has already used it or if you can give me a tip on that, it would be really greatly appreciated. Ive been searching the forums, but the search function is just hell.
Thanks in advance! :)

Try using signalR (http://signalr.net/). It's a communications library for client+server when you need to keep the connection open for a long time, like chats or file uploads. On the server, I'd set a variable to session, or somewhere, indicating the progress, supposing the server knows the file size. I haven't used it, but it would be where I go for such tasks.

Related

How to stream music in C# with PostgreSQL

I am trying to recreate some features of Spotify in C# using the PostgreSQL database.
The reason is simple, I want to gain more knowledge, and I think this is a good challenge.
But I ran into an obstacle that I've been standing for days. Spotify he doesn't download the music, he does her streaming, plays the music while it's downloaded.
However, I can't do this in C#, I'm using the PostgreSQL database.
I'm well locked in this part, I tried several implementations, but I think I'm not on the right track, and on the internet I imagine I'm looking wrong, otherwise I would have found it.
Do you have any guidance for this streaming process in C#? I've tried to read the large_object bytes from PostgreSQL, but couldn't.
Any suggestions or guides about the process are welcome.
You start by getting the file into the database or its network location into the database, whichever gives you better performance; Then start with creating an implementation of a bytestream. You want to be transmitting raw data to c#.
you then build a real time interpreter that takes in using your file format, one byte at a time, and plays the value associated with that section. does that make sense? this is simple to do with many libraries and the brunt of it is just figuring those out.
You seem like you've PROBABLY got that first part down, and are instead having issues with the database. A lot of things we did at my last company involved saving file network locations and indexing files on disk. You might be able to instead point your streamer to a file locally using a server, and instead transmit data from one point to another in that manner instead.
You seem more than capable of doing this just judging by your speech. I hope this comment was helpful, and if it was not I apologize as well. I would be interested in seeing your finished result.
for clarification here would be that workflow:
request for a song listed in table dbo.Songs
matches that song onto dbo.songlocation
streams from dbo.songlocation.location from the filename dbo.songlocation.songname = dbo.song.name and verified directory returns true
enjoyment of that music

Best way to let multiple .NET apps communicate with each other

So, first of all sorry for my bad english.
Back to the questio, i have a main app, with a tab control, each tab contain another .NET exe. These need to send infos to the main app. Example:
Each exe in a tab have a random generated guid every second and the main app need to catch this and show in a listview or something as long the exe is "alive".
Currently i'm using SQLite, and everytime a new exe is started this one write in a table. Before closing it this exe remove the recod from the table.
In the mainwhile, the main app retrieve this update table and show the "alive" exe and the random generated guid (every second). All works fine, the problem is that i need to abandon this method and remove the two dll of SQLite.
What i tried is:
UDP socket between the N clients and the main app, but is not so stable. And sometime some exe got freezed. (using TCP will be so "heavy" for the only purpose to send a short string. Right?)
Changing the window text of the other exe and retrive it via processinfo, but is not updating it, i get it just the first time string.
So, there is a way for that? In local. Like, i don't know.. user32 sendmessage maybe? Or this method is too invasive for just a short string?
Considering that the N sub exe are process "inside" the main one, there is not a way to obtain infos from child process?
Thanks for your help!
UDP does not guarantee delivery of the packet by-desing. Unless you implement your own confirmation protocol above it. But implementation itself should be stable.
Using TCP will provide similar results. You'll just have to deal with reconnect stuff.
SendMessage/PostMessage is the easiest and straight forward method. But it will not allow you to pass string directly. Take a look at RegisterWindowMessage to register your own message and SendMessage with HWND_BROADCAST handle. And you'll have to send pointer to your string. Since SendMessage is synchronous you should be teoreticaly fine with disposing of that message, but I haven't tried that. Another option would be storing string somewhere-else (registry, file) and sending just update notification using SendMessage. And the main app will read and delete that registry/file record.
Self hosted WCF with netNamedPipeBinding should work as well. But that would be propably too robust solution.

Find out on what place on a harddisk a program / file is installed

Let's say I have a file: test.txt and I save it on my harddisk.
Is there a way to determine on what (physical) spot the file is saved on the hard disk?
For example on vector 12 on track 10 of the hard disk.
I don't know if I got the terminology right of the above, but I hope you get what I mean.
I want to write of program wheer the user can point to a file and the program will find out where the file is on the HDD. Something like the old defrag (it's Windows ;) ) where it shows what parts of the disk is in use.
What is this called and can it be achieved? (I'm not looking for code (although exmaples are ok ofc), but rather whether it is possible)
P.S. The client will be Windows 7 (so think NTFS if it matters).
I'm pretty sure that doing that sort of low-level disk i/o in managed code is going to be...difficult, at best. Here's somebody that's done something like it:
http://codebrainz.ca/index.php/2010/05/23/low-level-disk-io-in-managed-net/
Anything you write to do something like this has to be hardware-dependent: unless you know what hardware you're talking to, you've got no idea how it physically stores data (e.g., a USB memory stick has neither platters, tracks nor sectors, nor does it spin. Yet, for all intents and purposes, it appears to be a disk).
Normally, you'd write some sort of device driver to accomplish this. This link
http://en.wikibooks.org/wiki/Windows_Programming/Device_Driver_Introduction
might help.
In Jeffrey Wall's WebLog you will find Defrag API C# wrappers. His GetFileMap method sems to come close to what you need.
It is possible from C++, so with a little interoping, you should be fine.
Look up FSCTL_GET_RETRIEVAL_POINTERS in the MSDN to get you started.

Sharp Pcap and multiple ICaptureDevices in c#.NET

im having a nightmare of a time trying to get sharp Pcap to send packets happily via multiple instances of ICaptureDevice. The problem is that If i use more than one instance of ICaptureDevice any existing ones will just drop out and no error is thrown.
I was wondering if you have any ideas on how to keep all instances of ICaptureDevice work happily. ( If you have had this issue)
Unfortunately I can not provide code examples as this is Proprietary software im building.
I have tried aggregrating all the packets into one queue stream and getting a single ICapDev to send them but i found this to be too slow for the device recieving them at the other end.
Many thanks for any help
Ok i had a talk with Chris - the use of CaptureDeviceList.New()[i] is advised instead of CaptureDeviceList.Instance[i].

POST request with PowerShell

I have got problem, I need to download graphics from next site
http://www.kakioka-jma.go.jp/cgi-bin/plot/plotSetNN.pl?lang=en
I am using PowerShell, I need to create POST request to Plot the image (see Plot button). The problem that I do now know how it's can be done in PowerShell. Before I used function 'System.Net.WebClient' for downloading, and created url for it with
I googled and find how POST request may be done in C#, and I tried to built them in one script. http://www.everfall.com/paste/id.php?2ppnztfqx3we
But it's not working, it's even do not print "Hello World", and I do not know how to get it's work.
But the main question - not get this code to work, but to find the easiest way to load that graphics, and it would be good if it would on Powershell.
I have seen "Http Rest" script, but it's to hard even to understand does it do what I need, I even do not talk about to modificate it's for my work. I need the simplest way, because my knowledge in programming it now good.
I wrote a series a while back on Splatting (a language technique in PowerShell V2). The last item in the series provides a wrapper on the Net.WebClient class that makes it easier to send requests via Post.
The blog explains a lot about how the client object works, and you can read that if you want:
http://blogs.technet.com/b/heyscriptingguy/archive/2010/10/22/make-windows-powershell-your-web-client.aspx
Or you can download the script directly from the Script Center Repository:
http://gallery.technet.microsoft.com/ScriptCenter/en-us/7e7b6bf2-d067-48c3-96b3-b38f26a1d143
Hope this Helps,
It sounds like curl could be useful for you. It will deal with the trickier aspects of posting data to a web service.
I've used it myself to download text and parse through it with PowerShell. I had a batch file to call curl, the batch file was called from a powershell script. Sounds the long way around but it worked quickly and I didnl't have to put much time in!
I'm on my phone and don't have any examples here, if you interested I can have a look for them later.
HTH,
Matt

Categories

Resources