Showing posts with label Silverlight. Show all posts
Showing posts with label Silverlight. Show all posts
Monday, April 18, 2011
Wednesday, April 6, 2011
Delete directory in IsolatedStorage
IsolatedStorageFile.DeleteDirectory works with empty directories only.
Usage:
I wrote the method for recursive deleting content of the directory:
using System.IO.IsolatedStorage;
. . .
public void DeleteDirectory(IsolatedStorageFile
fs, String dirName)
{
String
pattern = dirName + @"\*";
String[]
files = fs.GetFileNames(pattern);
foreach
(String fName in
files)
{
fs.DeleteFile(Path.Combine(dirName, fName));
}
String[]
dirs = fs.GetDirectoryNames(pattern);
foreach
(String dName in
dirs)
{
DeleteDirectory(fs, Path.Combine(dirName, dName));
}
fs.DeleteDirectory(dirName);
}
using
(IsolatedStorageFile fs = IsolatedStorageFile.GetUserStoreForApplication())
{
DeleteDirectory(fs, @"\Projects"); // directory "Projects" in the root will be deleted
DeleteDirectory(fs, @"\Projects"); // directory "Projects" in the root will be deleted
}
Wednesday, March 10, 2010
Silverlight: show image from database
// image1
is Image SL control
// blob
is table entity
//
BLOBASIMAGE has type byte[] (db type: image)
using
(MemoryStream stream = new MemoryStream(blob.BLOBASIMAGE))
{
try
{
BitmapImage
im = new BitmapImage();
im.SetSource(stream);
image1.Stretch = Stretch.Uniform;
image1.Source = im;
}
catch
(Exception)
{ // major reason:
wrong picture format. JPG is OK
image1.Source = null;
}
}
Subscribe to:
Posts (Atom)
