Esempio n. 1
0
 public static bool CheckDownloadExist(string fileName)
 {
     if (null == fileName || string.IsNullOrEmpty(fileName.Trim()) || null == m_Instance || null == m_Instance.m_LocalDownLoaded)
     {
         return(false);
     }
     fileName = UIWorkShopCtrl.GetValidFileName(fileName);
     return(m_Instance.m_LocalDownLoaded.Contains(fileName));
 }
Esempio n. 2
0
    public static void AddDownloadFileName(string fileName, bool byUploadPage) //true ByUploadPage , false ByWorkShopPage
    {
        if (null == m_Instance && null == m_Instance.m_LocalDownLoaded)
        {
            return;
        }
        if (byUploadPage)
        {
            m_Instance.mPageWorkShopCtrl.SetItemIsDownloadedByFileName(fileName);
        }
        else
        {
            m_Instance.mPageUploadCtrl.SetItemIsDownloadedByFileName(fileName);
        }

        fileName = UIWorkShopCtrl.GetValidFileName(fileName);
        m_Instance.m_LocalDownLoaded.Add(fileName);
    }
Esempio n. 3
0
    private bool SaveToFile(byte[] fileData, string fileName, string filePath, string fileExt)
    {
        if (!Directory.Exists(filePath))
        {
            Directory.CreateDirectory(filePath);
        }

        fileName = UIWorkShopCtrl.GetValidFileName(fileName);

        string TempPath = filePath;

        filePath += fileName + fileExt;

        int i = 0;

        while (File.Exists(filePath))
        {
            i++;
            filePath = TempPath + fileName + i.ToString() + fileExt;
        }

        try
        {
            using (FileStream fileStream = new FileStream(filePath, FileMode.Create, FileAccess.Write))
            {
                BinaryWriter bw = new BinaryWriter(fileStream);
                bw.Write(fileData);
                bw.Close();
                fileStream.Close();
            }
            return(true);
        }
        catch (Exception e)
        {
            Debug.LogError(string.Format("Save ISO to filepath:{0} Error:{1}", filePath, e.ToString()));
            return(false);
        }
    }