|
Thanks for the reply sir,
I want to achieve file transfer through c# console application by specifying remote system's domain,user name & password.
can it be done so..? pls help me..
No Defeat Is Final Until You Stop Trying!.......
|
|
|
|
|
The third example in the original link shows how to do that, I thought...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
sir didn't get u.. third example ??
No Defeat Is Final Until You Stop Trying!.......
|
|
|
|
|
If you follow the first link I gave you, then scroll down.
After the "Remarks" section there are three examples: Deleting, downloading, and then uploading a file from a remote site via FTPWebRequest.
The example you want is the third of these, and is about 1/4 of the way down the whole page.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
sorry for the wrong communication.
i will explain it clearly.
Consider machinA and machineB.
- A & B are located on different domains.
- B is having a network share path(ex: \\192.168.10.12\d$)
- Now i want to transfer a file abc.txt from machineA to share path on MachineB.
I am trying with File.copy() method bt was failed with longon failure as the servers are located on different domains.
So, is there a way that if i know MachineB logon account(domain,username&password) can i be able to transfer file??
pls guide me a way to achieve this.
No Defeat Is Final Until You Stop Trying!.......
|
|
|
|
|
You need to impersonate the account in order to access the other domain. Had you searched Google, you'd have found this[^] article which does exactly what you are trying to do.
|
|
|
|
|
Thanks for the reply sir,
Yes i had gone through that Link earlier, but i was stuck at LongonUser() part.
Will it accept localuser account or remote server's user account?
which username,password&domain i should give?
No Defeat Is Final Until You Stop Trying!.......
|
|
|
|
|
You need to give it the remote account details - that's the user you are trying to impersonate. It's no use giving a local account.
By the way, please don't cross post. I just found the same question posted in Q&A - if you post in multiple places, it's hard to see what advice you have been given, and the missing nugget of information can get lost because we haven't seen the other post.
|
|
|
|
|
Sorry .. my apologies..
No Defeat Is Final Until You Stop Trying!.......
|
|
|
|
|
You are quite impatient guy. This is a double post!
If you would be a bit more patient, later on I could give you an example!
|
|
|
|
|
Sorry .. my apologies for the impatience..
No Defeat Is Final Until You Stop Trying!.......
|
|
|
|
|
I'm making a project in c# that looks like Paint.Net
i hace a panel in the middel of the form
(form size=900,500 panel size=800,400)
when i load a bigger picture like 801,401 and above
i don't want to increase the panel size instead i want to reduce the pic's pixel
so that will fit into the original panel size.
can someone help me with that ?
|
|
|
|
|
It's difficult to give you a simple answer to that, as there are a lot of factors that are involved.
How are you showing the picture in the panel? Hopefully, you are handling the Paint event, and drawing it yourself. If not, why not?
How do you want to show the picture? Zoomed? Stretched? Proportional to the panel size, or the original image size? (i.e. if the panel is 800 x 400 and the picture is 1000x1000, what do you show - all the pixels? All the pixels horizontally, and some of the vertical ones? Or something else?)
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Also consider using a picturebox inside the panel. This has properties for scaling/zooming etc.
|
|
|
|
|
Hi,
I am having one form with yes and no button running in one thread. And one worker thread is running which will keep repeating it's task at every 4 sec.
While worker thread is running, and if i will click yes in other threads, program takes lot of time to execute the action to be performed by clicking yes button.
Because of this background of Main UI is not painted for that much of time period.
How I can solve this problem? Atleast background of Main UI should be repainted all the time.
Thanks in Advance..
|
|
|
|
|
It sounds as if you've done something very wrong. The form should be on the UI (startup) thread and your worker code on the background thread. If the background isn't doing actual work, it shouldn't normally be running at all, unless this is some kind of server process. It really depends on what you're doing, but it's customary to create the worker background object when needed and let it terminate itself when the work is done, though, that's not always possible or appropriate.
The other popular method is to run the background thread in two modes, work and polling. Work mode is obvious. This is where the thread is actually processing work. Polling mode is where the thread is checking some kind of variable every so often to see if there's work to be picked up and processed. This polling should be done in a loop that is delayed with a sleep for, say, once a second. The UI code, your Yes button code, should set the variable appropriately to get the background thread to kick off work.
|
|
|
|
|
The action that takes a long time should not be in the main UI thread; instead, that's what should be farmed out to a worker thread or a Task.
|
|
|
|
|
Hi all,
I am working on a an application that needs to do the following:
1. Query the registry for all the keys (approx. 100) that are written by another application and
2. Displays this information on a form.
3. Write this information to a log file.
I am using Visual Studio .NET 2010 on a Win 7 machine. The limitation I have to work with is that I have to use the .NET 3.5 framework since that is what is installed with Win 7.
I have steps 1 and 3 figured out but I have a question about step 2.
What control(s) should I use to display this information? The display itself can be very simple, for example:
REGISTRY KEY VALUE
KEY 1 0
KEY 2 20
KEY 3 0x3FF
...
NOTE: The Key names will be populated in advance by the application. The Values will be populated upon each query.
Should I use several TextBoxes? This appears to be the brute force method and not very scalable.
I tried playing with a ListView but it doesn't seem like I can update only the "Value" column.
What would you suggest?
|
|
|
|
|
Presumably your data container is a List<regkeys> where regkey has 2 fields Key and Value. Then bind that list as the datasource for the datagridview.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks, Mycroft.
I could create a list of registry key names and bind that list as the datasource to the datagridview. However, when the application runs, it will have to query the registry for each of those key names and then display the values of the key in the second column.
To clarify, when the application is first opened, I will have:
NAME VALUE
Key1 (blank)
Key2 (blank)
Key3 (blank)
...
When I click on "Run", I want to see
NAME VALUE
Key1 Value1
Key2 Value2
Key3 Value3
...
Should I then put Key1, Key2, Key3, etc... in a List?
Thanks!
|
|
|
|
|
Try it, you'll find that when your app runs it should get the value from the registry, locate the record in then List<> based on the key and add the value to the field. The DGV will automatically reflect the new data in the List<>.
Once you have created the List<> and bound it to the DGV you can ignore the DGV and work with the underlying data container - the List<>
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Why don't you use a Dictionary<string,string>. Then when the form opens you can populate each key of the KeyValuePair, bind the DGV to the Dictionary, then you can populate each value as and when you need to, or it becomes available, and rebind the DGV.
Just a thought
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
Thanks Mycroft, Wayne and Bob for your very helpful replies.
So, I have this now:
<code>// In Form1.Designer.cs
private System.Windows.Forms.DataGridView dgv_static_keys;
</code>
<code>// In Form1.cs
Dictionary<string, string> dict_static_keys = new Dictionary<string, string>
{
{"Key1", "Value1"},
{"Key2", "Value2"},
{"Key3", "Value3"},
};
BindingSource bindingsource = new BindingSource();
bindingsource .DataSource = dict_static_keys;
dgv_static_keys.DataSource = bindingsource;</code>
If I were to now update the Dictionary with a new key, say
<code>
dict_static_keys.Add("Key4", "Value4");
</code>
How do I get the DataGridView to update?
I tried this
<code>dg_static_keys.DataSource = dict_static_keys.ToList();</code>
but is there a better solution?
|
|
|
|
|
That's why I suggested using a BindingList, because it updates BindingSources that are hooked to it when the list is changed. It looks like BindingSource.ResetBindings is a slightly less brute force way to refreshing the binding if you don't want to use BindingList.
|
|
|
|
|
I would use a DataGridView, bound to a BindingList<RegistryEntry>, where
class RegistryEntry {
public string Key { get; private set; }
public string Value { get; internal set; }
}
... so the data binding only works off the (public) getters and therefore the grid is read-only.
You can update extra columns in a ListView, though. Check out ListViewItem.Subitems[0][^]. A ListView in details mode or a DGV comes down to a personal preference for the appearance, for a task like this. (It is not possible to edit subitems of a list view though, so if you want the user to be able to modify values before logging then a DGV is the way to go.)
|
|
|
|