title: File reading and writing in c#
body: <p>My Code is</p>
  
  <pre><code>        try
          {
              string mtellThemePath = ConfigurationManager.AppSettings["mtellThemePath"] == null ? Server.MapPath("~/App_Themes/") : ConfigurationManager.AppSettings["mtellThemePath"].Contains("%%") ? Server.MapPath("~/App_Themes") : ConfigurationManager.AppSettings["mtellThemePath"];
  
              string[] folderPaths = Directory.GetDirectories(mtellThemePath);
              string currentSurveyThemeName = hfSurveyName.Value + "_" + hfClientId.Value;
              string cloneSurveyThemeName = lstSurvey[0].SurveyName + "_" + Identity.Current.UserData.ClientId;
              string cloneSurveyThemePath = mtellThemePath + "\\" + lstSurvey[0].SurveyName + "_" + Identity.Current.UserData.ClientId;
  
              string cssFile = cloneSurveyThemePath + "\\" + cloneSurveyThemeName + ".css";
              string skinFile = cloneSurveyThemePath + "\\" + cloneSurveyThemeName + ".skin";
  
              string FileContentCSS = string.Empty;
              string FileContentSkin = string.Empty;
  
              foreach (string oFolder in folderPaths)
              {
                  if (oFolder.Split('\\')[5] == currentSurveyThemeName)
                  {
                      string[] cssSkinFiles = Directory.GetFiles(oFolder);
                      foreach (string objFile in cssSkinFiles)
                      {
                          if (objFile.Split('\\')[6].Split('.')[1] == "css")
                          {
                              FileContentCSS = File.ReadAllText(objFile);
                          }
                          if (objFile.Split('\\')[6].Split('.')[1] == "skin")
                          {
                              FileContentSkin = File.ReadAllText(objFile);
                          }
                      }
                  }
              }
              Directory.CreateDirectory(cloneSurveyThemePath);
              File.Create(cssFile);
              File.Create(skinFile);
              if (FileContentCSS != string.Empty)
              {
                  File.WriteAllText(cssFile, FileContentCSS);
              }
              if (FileContentSkin != string.Empty)
              {
                  File.WriteAllText(skinFile, FileContentSkin);
              }
              return lstSurvey[0].SurveyGuid;
          }
          catch (Exception ex)
          {
              throw ex;
          }
  </code></pre>
  
  <p>It is giving error as:</p>
  
  <blockquote>
    <p>The process cannot access the file
    'D:\Projects\Mtelligence\Mtelligence.Web\App_Themes\Clone_ForCloneTest_-1\Clone_ForCloneTest_-1.css'
    because it is being used by another process.</p>
  </blockquote>
  
  <p>Please Help me ..........
  how to solve this</p>
  
  <p>Iam trying to read .css,.skin files from a folder and write those same files in another folder with different name</p>