|
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
|
|
|
|
|
i want code for a program:
i want to enter a number in between 4000 and 8000.also that entered number must contain a digit 2.otherwise it show invalid. eg:4002,4012,5222.
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:47am.
|
|
|
|
|
thanks for your kind reply.
I am a fresher in this field..
Can u please give me a detailed explanation?
Then it will be very helpful to me...
|
|
|
|
|
And I want money
Anyway here's one way to do it:
1)Check if number is between 4000 and 8000
2) If so then check if it contains a "2". Something like this:
string nr = yourNumbert.ToString();
if(nr.Contains("2")){//do stuff
else{//complain about it
|
|
|
|
|
thanks for your kind reply.
I am a fresher in this field..
Can u please give me a detailed explanation?
Then it will be very helpful to me.....
|
|
|
|
|
thanks for your kind reply.
I am a fresher in this field..
Can u please give me a detailed explanation?
Then it will be very helpful to me...
|
|
|
|
|
thanks for your kind reply.
I am a fresher in this field..
Can u please give me a detailed explanation?
Then it will be very helpful to me....
|
|
|
|
|
It's getting Exam Time Again... Bram van Kampen
|
|
|
|
|
Unfortunately, I'll have to work hard and save up.
|
|
|
|
|
Good Morning,
When my application opens, it checks a version number from an online database to determine if it is using the most current version available. If not, I need it to be able to download the most current version from an online server and then install the application update automatically. I know we see examples of this every day, such as security updates in Windows or online checks for anti-virus programs. The check and automatically close if not installed are already working fine and return a Boolean. How do I force and install the download?
Thank You, Pat
|
|
|
|
|
|
Thank for your answer. I have marked it as correct for this issue. I was able to use it to get the string of code that I needed to resolve the download problem. Now, I need to be able to find a way to automatically install the download. Best Regards, Pat
|
|
|
|
|
Hi all,
I have a NOOB question, when developing a custom user control how can you reference other classes or use a partial class? For some reason when I try to reference another class it can not find it. I tried using the same namespace in the separate class file and tried putting it in the bin directory without any luck. Thanks for the Help!
-Andy
|
|
|
|
|
If the class is in another assembly you must remember to add a reference before it will be available.
Perhaps if you showed a bit of the code we could evaluate it. And don't forget to format the code using the pre tags. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks Mark, I was hoping it was something simple, sometimes the easiest things give you the most problems, here is a layout of my code....
myControls.ascx.cs:
namespace myControls
{
public partial class MyUserControl : System.Web.UI.UserControl
{
public MyEnum myEnum;
protected void Page_Load(object sender, EventArgs e)
{
(.......)
}
}
}
myControls.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="myControls.ascx.cs" Inherits="myControls.MyUserControl" %>
<div>
</div>
myControls.Support.cs
namespace myControls
{
public enum MyEnum
{
Day,
Week,
Month,
}
} Thanks again,
Andy
|
|
|
|