|
harold aptroot wrote: if Data is a property with side effects
...which we are all really hoping it isn't. If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
I spent one short evening last week defining a library of user controls for my project to track substation electrical equipment. I had found myself duplicating efforts creating various forms that use the same information, and found it tedious to switch back and forth tweaking properties to make the appearance consistent among forms. So I grouped various data items that I was recreating for each form and spent a few hours creating user controls in a library.
For example, a recloser has some basic nameplate information - serial #, manufacturer, type, etc. Reclosers also have a trip coil, and a close coil, and some but not all have ground trip coils. Each coil has its own voltage and current ratings, and a programmable sequence of trip-wait-close steps it can use to restore service on a faulted line. So I made a generic nameplate control, a coil control, and a sequence control. With these new controls I can play with the visibility properties to display only the elements that are relevant to a specific function or recloser type. At least, that was my plan.
Tonight I spent 30 seconds creating a test Form app, referenced my new library, and dragged the controls onto the form. It looks exactly the way I wanted it to, and behaves exactly as planned when I fiddle with the control properties! Now it's time to add controls to describe transformers, load tap changers, regulators, capacitors, and power circuit breakers to the library.
I'm jazzed! In 10+ years wasted trying to do something useful with Visual C++ I never managed to do this much at all, let alone in only a few hours!
Many thanks to all the patient helpers I've discovered here - programming is FUN again! "A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Did you mean to post this in the C# forum? Seems like it would make a good Lounge post.
|
|
|
|
|
It works either way, and this is where the folks who helped hang out. "A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
I am newbie to webservices
I am trying to learn about them, but got struck in the first place itself. Please help me out.
My service.cs in the web service.
--------------------------------
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://localhost:1458/forumservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
}
[WebMethod]
public string welcome(string name)
{
return "Welcome " + name;
}
}
now on a button click from another web page
protected void Button1_Click(object sender, EventArgs e)
{
try
{
soapMessage =
@"
<?xml version=""1.0"" encoding=""utf-8""?>
<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">
<soap12:Body>
<welcome xmlns=""http://localhost:1458/forumservices/"">
<name>Rajas</name>
</welcome>
</soap12:Body>
</soap12:Envelope>";
WebClient mClient = new WebClient();
Response.Write(System.Text.Encoding.ASCII.GetString(mClient.UploadData("http://localhost:1458/forumservices/Service.asmx", "POST", System.Text.Encoding.ASCII.GetBytes(soapMessage))));
}
catch (System.Net.WebException ex)
{
if (ex.Response != null)
{
Stream strm = ex.Response.GetResponseStream();
StreamReader sr = new StreamReader(strm);
Response.Write(sr.ReadToEnd());
}
else
{
Response.Write(ex.InnerException.ToString());
}
}
}
The compilation is fine, but i keep getting some errors as below
"The remote server returned an error: (500) Internal Server Error."
Please help me out
I had posted the exam same thing in ASP.NET forum, but got no replies.Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
|
if you wanted to change say textbox1 datasource to be that of checkbox1 datasource how would you go about doing that ? i looked for something like textbox1.datasource but didn't find anything. I know you can set it in properties but i wanted to set it in code if possible..
thanks
|
|
|
|
|
what do you mean by binding a textbox with datasource, you can simpley write textbox.text for binding any value in that.
|
|
|
|
|
well my original idea was that the reason one of my control was not populating correctly was because it was bound to a different binding source but I don't think that is problem at all. i used
textbox.databinding.add("Text",bindingnavigator.bindingsource,"SurrogateNumber"); then of course i get double binding errors when I do that because it is already bound. I don't know I'll figure something out. Kinda strange that the data comes back but that one control only gets the first instance of the filter whenever all the data is there.
Thanks for trying to help though.
|
|
|
|
|
I figured it out i had to use dataloadoptions to link all the tables together and it works fine.
|
|
|
|
|
i have created a encryption and decryption program. what i would like to do is have a CD with my decryption.exe program on it and a encrypted file. When the decryption.exe is launced i want to grab the encrypted file on the CD and either copy or move it to a location i specify on the C: drive. from here i will do the other necessary work. The problem i am having is when i tried to use either File.Copy or File.Move i am being thrown the error "Access E: drive is denied" (i am an admin on the computer). The question i have is it possible to move the encrypted file to the C: drive and if so could you point me in the right direction to do so. i would appreciate any help I'm really stuck here, also if you would like to see any code please let me know and i will post it here.
|
|
|
|
|
Erm, I'm just pointing this out, I don't know how your stuff works or where the Keys are stored or anything, but doesn't packaging up the encrypted information and the decryption tool break the security a little Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
yeh i see what your saying, basically the way i am controlling this is like this, the user will choose the file to be decrypted which will be on the on the CD, once they choose that file i want to move it to somewhere i specify on the C: drive then i will have the user click my decrypt button(where a new form is launched to input a password i supply(I'm using the password for both the iv and key) and it will decrypt and unzip the data and automatically launch a web browser in a form that is going to be linked to the index.html in the unzip folder.
after the new form or my program is closed i want to erase everything i created on the C: drive, i realize that security isn't perfect here but the fact is the end user can have the unencrypted data, but i understand what your saying packaging the decryption tool with the data is risky but without my password to decrypt the file its worthless. im using Aes 256 so its going to take some time to decrypt my password if some one really wanted it. hope i answered your question?
if not ill try again just ask away, thanks for the comment
|
|
|
|
|
Everything you need is in System.IO , for example the File class has Copy and Delete methods. Basic code would look like this:
string sourcePath = ".....";
string destinationPath = "......";
File.Copy(sourcePath, destinationPath);
File.Delete(destinationPath);
If I understand your post, there is still a problem with packaging up the decryption utility.
a) If your password is not the key then the encryption is only as good as the password strength (and the code to verify the password). It is also open to automated attempts at finding the password.
b) If you use both the key and the iv as the password, you need will need to send these as plain text to the user.
c) Along side b, Long keys are unlikely to be entered correctly by the user, short values are are susceptible to brute-force attacks).
d) You will need to obstifucate your decrypter to. PosssiblyAntoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
yes i have tried the File.Copy and the File.Move. i know the way i did them is right because if i run my program with the file on the C: drive and not a CD then it works. but when i try to get the file to copy or move from CD which happens to be my E: drive i get the error.
decryption failed Access to the path E:\bb.zip.dpa is denied.
if i have my encrypted file anywhere but on my CD then my program works fine. below is my code for when i open the file with a file browser dialog and here i try to copy the file. also i point out where it breaks and throws the Access is denied error
private void btnOpen_Click(object sender, EventArgs e)
{
ofdMain.Title = "Select file to Decrypt";
ofdMain.Filter = "Crypt files (*.dpa)|*.dpa";
if (ofdMain.ShowDialog() == DialogResult.OK)
{
txtBoxDecrypt.Text = ofdMain.FileName;
OutputFileNameDe();
string path = txtBoxDecrypt.Text;
string path2 = @"c:\temp2\MyTest.txt";
try
{
if (!File.Exists(path))
{
using (FileStream fs = File.Create(path)) {}
}
if (File.Exists(path2))
File.Delete(path2);
File.Move(path, path2);
Console.WriteLine("{0} was moved to {1}.", path, path2);
if (File.Exists(path))
{
Console.WriteLine("The original file still exists, which is unexpected.");
}
else
{
Console.WriteLine("The original file no longer exists, which is expected.");
}
}
catch (Exception ex)
{
Console.WriteLine("The process failed: {0}", ex.ToString());
}
}
}
thanks again for all your help, if i need to provide anything else let me know.
|
|
|
|
|
Aha! File.Move won't work as the CD is read-only and Move attempts to delete after copy. You should do a straight copy, then delete the temporary file when the decryption is done.
I'd also strongly suggest renaming your file paths something *like* SourcePath , TempFilePath and DecryptedFilePath as this saves a lot of potential pain if these get confused!
Another thing that occurs to me is, if memory serves, decryption happens in a stream, writing this out directly to the file via a FileStream would probably be more efficient than copy /decrypt/delete.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
i just ran my app from a flash drive it worked perfect why am i getting access denied when i run my application and file from a CD???
|
|
|
|
|
A move would imply a "copy & delete" operation, and that would fail on a CD. Try again after you replace the File.Move with a File.Copy as keefb suggested I are Troll
|
|
|
|
|
here is my code i used to copy the file, i get the same error any idea why ??
private void MoveFile()
{
System.IO.File.Copy(sourceFile, destFile, true);
if (System.IO.Directory.Exists(sourcePath))
{
string[] files = System.IO.Directory.GetFiles(sourcePath);
foreach (string s in files)
{
fileName = System.IO.Path.GetFileName(s);
destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(s, destFile, true);
}
}
else
{
Console.WriteLine("Source path does not exist!");
}
}
|
|
|
|
|
Where does this break, and what is the message?
In the code:
shadowthief_03 wrote: foreach (string s in files)
{
// Use static Path methods to extract only the file name from the path.
fileName = System.IO.Path.GetFileName(s);
destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(s, destFile, true);
}
Don't re-use the variables fileName or destFile , declare with different names, or you'll get the world of pain later.
There is a danger (in fact I *think* it is certain) that the loop above will re-copy the file copied in the first line inside the method you posted. You will get an access denied message if that file is marked as read only on the file system (i.e. recopying onto a readnly file already copied). You could try removing that line from the code.Antoine de Saint-Exupery: Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
|
|
|
|
|
wait i got it figured out you where right about the copy, and i wasn't using file.copy the right way thanks to everyone for your help i really appreciate it
|
|
|
|
|
shadowthief_03 wrote: here is my code i used to copy the file, i get the same error any idea why ??
It might be because there's already a file on your system. You're mentioning that you want to overwrite this file if it exists, in the File.Copy statement;
System.IO.File.Copy(s, destFile, true); This will fail with a "UnauthorizedAccessException" if there's a pre-existing file that's read-only. A file that has been copied from CD will have the read-only flag set, preventing it from being overwritten by a File.Copy .I are Troll
|
|
|
|
|
hi
How to Load & Save to val's in app.config file ?
for example: to save & to load Connection string
thank's in advance
|
|
|
|
|
1) to add in the xml:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="MyConfig" value="MyValue" />
</appSettings>
</configuration>
2) to load/read something like this:
string myConfig =
System.Configuration.ConfigurationSettings.AppSettings["MyConfig"];
|
|
|
|
|
Hello all,
I am trying to create a UserControl that has some Style properties, I am not sure how to get the Style or StyleCollection to show up correctly in the Designer. I can set
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
and it will display all the Style types without a group i.e. Style-BackColor, Style-BorderColor etc. But when I set
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
the Style property does not show up at all. If anyone knows of a good article on this that would be a great help also.
Thanks!
-Andy
|
|
|
|