|
my app can have multiple icons through win32 res but the problem is that it do not support alpha. Is there anyway other way ?
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi there
I have written an application that attempts to transfer a file using the Socket class. I am able to set up the command socket and the data socket just fine, and transfer *most* of the file. The problem is that the file size on the server after being transferred is smaller than the number of bytes my software says it transferred. If I use a third-party FTP product, such as Core FTP, to download the file I just uploaded, the file is still too short by less than the length of my transfer buffer.
My upload code is:
// Get a separate socket for the data transfer
Socket dataSocket = GetDataSocket(cmdSocket);
// Start uploading!
int numBytesRead = 0;
byte[] byteBuffer = new byte[TRANSFER_BUFFER_SIZE];
int m_BytesTransferred = 0;
while ((numBytesRead = fs.Read(byteBuffer, 0, TRANSFER_BUFFER_SIZE)) > 0 && !m_Cancel)
{
try
{
dataSocket.Send(byteBuffer, numBytesRead, SocketFlags.None);
m_BytesTransferred += (long)numBytesRead;
// This is to let my UI update the progress meter
Thread.Sleep(20);
}
catch (SocketException ex)
{
break;
}
}
// Finished with the file, so close it.
fs.Close();
if (dataSocket.Connected)
{
Thread.Sleep(500);
dataSocket.Shutdown(SocketShutdown.Both);
dataSocket.Close();
}
My download code is:
Socket dataSocket = GetDataSocket(cmdSocket);
string retString = "";
m_BytesTransferred = 0;
// Set the time when we will give up on the transfer
DateTime endTime = DateTime.Now.AddSeconds(5.0);
int numBytesRecd = 0;
byte[] transferBuffer = new byte[TRANSFER_BUFFER_SIZE];
while (endTime > DateTime.Now && !m_Cancel)
{
numBytesRecd = dataSocket.Receive(transferBuffer, TRANSFER_BUFFER_SIZE, SocketFlags.None);
if (numBytesRecd <= 0)
{
break;
}
fs.Write(transferBuffer, 0, numBytesRecd);
m_BytesTransferred += (long)numBytesRecd;
// Reset the time when we will give up if we just received some bytes
endTime = DateTime.Now.AddSeconds(10.0);
Thread.Sleep(20);
}
// All done writing to the file
fs.Close();
if (dataSocket.Connected)
{
dataSocket.Close();
}
I have verified that the portion of the file that has been transferred is the same as the original file. I have even put in a Thread.Sleep(500) to wait for the last buffer to transfer before calling Socket.Shutdown() and Socket.Close(). Nothing has worked. Any suggestions?
|
|
|
|
|
I'm not sure where you're losing data, but you can greatly simplify your code
by implementing a simple protocol - the simplest being send a header first that
indicates how many bytes of data will follow. This header could be a simple integer.
Member 3216808 wrote: I have even put in a Thread.Sleep(500) to wait for the last buffer to transfer
You shouldn't need to use Sleep() anywhere, and using it like that is really bad.
Even if it was accurate, what if it took 501ms? You can't possibly throw meaningless
millisecond values at it and hope something works. You're also definitely not guaranteed
20ms accuracy on Sleep()...
Other than that, I can't tell what's up - your code doesn't look like it has anything to do with
FTP - at least not the standard FTP. You haven't indicated what socket protocol you're using, whether
you're using blocking/non-blocking sockets, etc...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
This is how I get my data socket:
dataSocket = new Socket(endPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
I send data on the socket after sending a STOR command on the command socket; at least, that is what I call the socket where text is sent and received. When the data transfer is "complete," I get an appropriate text message on the command socket saying that the transfer completed, and giving info on how long the transfer took.
This is my first time using sockets, so I am not sure what else you are asking. I used the Thread.Sleep() in desperation when I realized that some data was disappearing somewhere. The Thread.Sleep(20) is just so the thread will yield and let other things happen in the UI - the exact timing is unimportant.
I am not sure that adding a header would be too useful - I would be able to detect that data had disappeared, but I would have no way to correct the problem.
|
|
|
|
|
Hi,
I there any special reason to use socket?? , i am just asking this question because in .net there are better way of transferring data using ftp , one of those method is to use 'FtpWebRequest' class , which is inbuilt in .net (under the namespace System.Net), following is the code you may use to send a file to an FTP server
using System;
using System.IO;
using System.Net;
using System.Text;
namespace Examples.System.Net
{
public class WebRequestGetExample
{
public static void Main ()
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.yourFtpLocation.com");
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential ("username","Password");
StreamReader sourceStream = new StreamReader("FileYouWantToUpload.txt");
byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
response.Close();
}
}
}
}
I hope this helps
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
Hi everybody,
i have a little problem. I'm writing a console application that send(via socket)a simple string ( "P" ) to a server. If this app connect directly to server, i get a right answer. But this app must connect on a proxy(Linux Squid) to contact my server.
How can i route, my socket string, via proxy?
Thanks.
modified on Wednesday, January 14, 2009 10:12 AM
|
|
|
|
|
Hi ,
I think that is not something we can do through our application , that can be done through the setting on the proxy , on the proxy you need to froward the port you are using , if this forwarding is blocked you will not be able to connect to the server.
I am not 100% sure as i have never tried , but this is the first thought that came to my mind.
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
I found a workaround.
On my client, i made a static route setting my server ip with my proxy as gateway.
Now, all the connection to my server go through a proxy.
|
|
|
|
|
Gr8
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
I have created a DataRowView so:
DataRowView repRow = (DataRowView)guarantorBinding.Current;
How can I get the value of the column "Surname" from the first row in guarantorBinding please?
|
|
|
|
|
I've not got time to test it but if you can cast the first column of the DataRowView as a DataColumn, you can access the ColumnName Property:
<br />
string colName;<br />
DataRowView repRow = (DataRowView)guarantorBinding.Current;<br />
colName = ((DataColumn)repRow[0]).ColumnName;<br />
It definitely isn't definatley
|
|
|
|
|
Many thanks for the reply. Unfortunately, that didn't work for me. Any further input would be much appreciated.
It's one of those annoying things that you sniff around for a while until the correct syntax revelas itself.
|
|
|
|
|
Damn! My first thought was actually that, since this is an object which only represents a row of data within the context of a GridView etc, that it might not actually contain the meta-data... I'll try and have a dig around and see if I can find out for sure.
It definitely isn't definatley
|
|
|
|
|
|
I've used Redgate's .NET Reflector tool to look at the code for DataRowView. The column accessor property looks like this:
<br />
public object this[string property]<br />
{<br />
get<br />
{<br />
DataColumn column = this.dataView.Table.Columns[property];<br />
if (column != null)<br />
{<br />
return this.Row[column, this.RowVersionDefault];<br />
}<br />
if ((this.dataView.Table.DataSet == null) || !this.dataView.Table.DataSet.Relations.Contains(property))<br />
{<br />
throw ExceptionBuilder.PropertyNotFound(property, this.dataView.Table.TableName);<br />
}<br />
return this.CreateChildView(property);<br />
}<br />
set {}<br />
}<br />
so it looks like you can access the column name property from :
<br />
repRow.DataView.Table.Columns[0].ColumnName<br />
I'd really recommend getting a copy of the tool - I've found it useful in loads of situations. It's available for free here[^].
It definitely isn't definatley
|
|
|
|
|
I've just read this message again and think I might have been talking at crossed purposes - I've been looking for a way to access the name of the column rather than the value... To access the column value you'd simply use the accessor method:
<br />
repRow["Surname"].ToString()<br />
This assumes that guarantorBinding.Current is the first line in the collection - is this correct? If not, what sort of object is guarantorBinding? Chances are it will have a 'Rows' collection so you'd access the first row using something like guarantorBinding.Rows[0] .
It definitely isn't definatley
|
|
|
|
|
Many thanks for your reply.
GuarantorBinding is a DataSet DataTable. The current position may not be at 0, and I want to find the value for a column for the row which is at position 0 without changing the current position.
Hope that makes sense ...
|
|
|
|
|
Accessing the row using the indexer won't affect the enumerator (Current is an implementation of the IEnumerable interface) so you can use this without affecting anything the current position.
It definitely isn't definatley
|
|
|
|
|
Ah! I see. It was just me being thick.
Many thanks again for all your input.
|
|
|
|
|
Hi,
In C++ to contact with files we have FILE type but in C# I dont't know how to do that. I can't find any material or document about this problem. Please help me.
Thanks
sm
|
|
|
|
|
Look into the System.IO namespace, particularly the classes that begin with File (File, FileInfo, FileStream).
|
|
|
|
|
you say that as if you have looked.
I cant image you did a search for anything related to files in c# and found nothing!!!
do you need something specific about the file, or from the file?
|
|
|
|
|
|
how can i open project c# by visuel stodio 2005
|
|
|
|
|