我要在IsolatedStorage下存储很多图片文件,如何实现?
如果有的话请给个例子。

解决方案 »

  1.   

    重复调用SaveImage可以存多个Image文件,重名的不会存 void SaveImage (string imgPath)
            {
                IsolatedStorageFile isfile = IsolatedStorageFile.GetUserStoreForDomain();            if(isfile.GetDirectoryNames("Images").Length == 0)
                {
                    isfile.CreateDirectory("Images");
                }
                string savePath = @"Images\" + Path.GetFileName(imgPath);
                if (isfile.GetFileNames(savePath).Length == 0)
                {
                    IsolatedStorageFileStream imgFileStream = new IsolatedStorageFileStream(savePath, FileMode.CreateNew, isfile);
                    FileStream fs = new FileStream(imgPath,FileMode.Open);
                    byte[] readbuffer = new byte[8192];
                    
                    while(true)
                    {
                        int readSize = fs.Read(readbuffer,0,8192);
                        if(readSize > 0)
                        {
                            imgFileStream.Write(readbuffer,0,readSize);
                        }
                        else 
                        {
                            break;
                        }
                    }                readbuffer = null;
                    fs.Close();
                    imgFileStream.Flush();
                    imgFileStream.Close();
                }        }
      

  2.   

    我做的是一个桌面程序,IsolatedStorageFile.GetUserStoreForDomain();改成IsolatedStorageFile.GetUserStoreForUser();可以吗?
    用在抓图程序里
      

  3.   


    GetUserStoreForApplication  获取与调用代码的应用程序标识对应的用户范围的独立存储。  
    GetUserStoreForAssembly  获取与调用代码的程序集标识对应的用户范围的独立存储。  
    GetUserStoreForDomain  获取与应用程序域标识和程序集标识对应的用户范围的独立存储。
    只有这3种获取方式,没有你说的那个API你想覆盖去掉判断就行: if (isfile.GetFileNames(savePath).Length == 0)
      

  4.   

    你用的是.NET策略啊!!
    没用过!!