.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Accessing hidden files and write in it

Posted By: subash     Posted Date: June 09, 2009    Points:2   Category :Windows Application
Hi

i have a text file which is in hidden format.My question is how to write a text inside this hidden text file using c#.When i try this,It shows error like"Access to the path "C\Mtext.txt" is denied".Any help i really appreciate

Thanks
Subash

Responses
Author: Amit Mehra          Accepted Answer   
Posted Date: June 10, 2009     Points: 10   

HI,
There is not straight forward approch to access/ write into hidden file however you can take this approch to write inot hidden files.

1)Set File as Visible so it can be overwritten


FileInfo myFile= new FileInfo(Environment.CurrentDirectory + @"\Files.File.txt");
myFile.Attributes = FileAttributes.Normal;


2)Overwrite Files

File.Copy(Environment.CurrentDirectory + @"\Files\File.txt", Environment.CurrentDirectory + @"\Files\File2.txt", true);

3) Set File as Hidden

FileInfo myFile= new FileInfo(Environment.CurrentDirectory + @"\Files\File2.txt");
myFile.Attributes = FileAttributes.Hidden;


Hope this will help you

Thanks,
Amit
Please "Mark As Answer " if this post help you.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend