PDA

View Full Version : سوال: مخفی کردن فایل های متنی



morteza@z
دوشنبه 30 آبان 1390, 12:11 عصر
سلام می خوام کد مخفی کردن فایلهای متنی(text) در داخل برنامه را کمکم کنید با تشکر.

Hybrid
دوشنبه 30 آبان 1390, 14:06 عصر
سلام دوست عزیز ، شما میتونی از تابع SetAttr به طور مستقیم استفاده کنی یا میتونی اول فضای نامی system.io رو در برنامه فراخوانی کنی و بعد صفت یا صفاتی (مانند مخفی کردن) رو به فایل مورد نظرتون نسبت بدین ....اینم یه مثال ..


Imports System.IO
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
File.SetAttributes("c:\siavash.txt", FileAttribute.Hidden And FileAttribute.ReadOnly)
End Sub
End Class

pouyansaraf
دوشنبه 30 آبان 1390, 14:37 عصر
سلام
به نظر من حتما فایل هایتان را در IsolatedStorage ذخیره کنید تا فقط خودتان دسترسی داشته باشید
چون حتا اگر فایل هایتان را هم از نوع سیستمی کنید باز هم میتوانید در ویندوز آنها را مشاهده نمایید

Imports System.IO
Imports System.IO.IsolatedStorage

برای ساختن یک فایل IsolatedStorage

Dim IsoStore As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForAssembly
Dim IsoFile As IsolatedStorageFileStream = New IsolatedStorageFileStream("mytextfile.txt", FileMode.Create, IsoStore)
Dim sw As New StreamWriter(IsoFile)
sw.WriteLine("my computer name is: " & My.Computer.Name)
sw.Close()


برای خواندن از یک فایل IsolatedStorage

Dim IsoStorage As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForAssembly
Dim IsoFile As IsolatedStorageFileStream = New IsolatedStorageFileStream("mytextfile.txt", FileMode.Open, IsoStorage)
Dim sr As New StreamReader(IsoFile)
MsgBox(sr.ReadToEnd.ToString)
sr.Close()