read phicture and write xml; leer imagenes de un folder y escribir xml

public string readXml(string strUrlimages, string strFormat, string strNameFile)
{
if (!string.IsNullOrEmpty(strUrlimages) || !string.IsNullOrEmpty(strFormat))
{
string[] filePaths = Directory.GetFiles(@"" + strUrlimages + "", "*." + strFormat + "", SearchOption.AllDirectories);
StringBuilder resultString = new StringBuilder();
string[] listFiles;
string[] arraylistImg;
string[] splitNameImg;
string[] splitNameImgFlag;
string flagNameImg = string.Empty;
string partNameFile = string.Empty;

int flag = 0;
ArrayList listImg = new ArrayList();
string contactAllImg = string.Empty;


for (int j = 0; j < filePaths.Length; j++)
{
listFiles = filePaths[j].Split('\\');
for (int k = listFiles.Length; k != listFiles.Length - 1; k--)
contactAllImg += listFiles[k - 1] + "|";
}

arraylistImg = contactAllImg.Split('|');

for (int i = 0; i < arraylistImg.Length; i++)
listImg.Add(arraylistImg[i]);

///This order ac the array
listImg.Sort();


for (int k = 1; k < listImg.Count; k++)
{
partNameFile = listImg[k].ToString();
flagNameImg = listImg[k - 1].ToString();

splitNameImgFlag = flagNameImg.Split('_');
splitNameImg = partNameFile.Split('_');

//if (splitNameImgFlag[0].ToUpper() == splitNameImg[0].ToUpper())
//{
// //flag = flag + 1;
// // resultString.AppendFormat("{0}", partNameFile);
// //if (flag == 3)
// // resultString.AppendFormat("", partNameFile);

//}
//else
//{
// flag = 1;
// resultString.AppendFormat("{0}", partNameFile);
//}

if (splitNameImgFlag[0].ToUpper() != splitNameImg[0].ToUpper())
resultString.AppendFormat("", splitNameImg[0].ToUpper());


}
if (!string.IsNullOrEmpty(strNameFile))
return writeXmlfile(strNameFile, resultString.ToString(),strUrlimages);
else
return "Error with the file name. Please check your data";
}
else
return "Error in the pahs and format img. Please check your data";
}

public string writeXmlfile(string strNameFile, string strResult,string strpahs)
{


string path = Server.MapPath("~/" + strNameFile + ".xml");
using (XmlTextWriter writer = new XmlTextWriter(path, Encoding.UTF8))
{
writer.Formatting = Formatting.Indented;
writer.WriteStartElement(strResult);
writer.Close();
}

return strResult;
}

Comentarios

Entradas populares