public int updateMedia(string sDirectory, string sStartDirectory, int iFolderId, int iMediaType, int iStructure) { int iMediaId = 0; String sPath; try { sPath = sDirectory.Substring(sDirectory.IndexOf(sStartDirectory) + sStartDirectory.Length + 1);; } catch { MessageBox.Show("In starting directory exists movies witch is not in subfolders."); return(-1); } String sFOlderName = sPath; if (sPath.LastIndexOf("\\") >= 0) { sFOlderName = sPath.Substring(sPath.LastIndexOf("\\") + 1); } if (iMediaType == 2 && hasSeasones(sFOlderName))//serija koja ima sezone { try { sPath = sPath.Substring(0, sPath.LastIndexOf("\\")); } catch { } } //select media if exists end return MediaId foreach (DataRow dr in DataBase.executeQuery("select id from mt_media where path= '" + duplicateApostrof(sPath) + "' and folder = " + iFolderId).Rows) { return(int.Parse(dr.ItemArray[0].ToString())); } String sNaziv = mediaName(sPath); String sYear = getYear(sPath, iMediaId, iStructure); String sGenre = getGenre(sPath, iMediaType, iStructure); String sType = "Movies"; if (iMediaType == 2) { sType = "Series"; } //insert media iMediaId = getMaxId("mt_media") + 1; String sQuery = "insert into mt_media(id,folder,path,name,year,genre,ratings,fl_watched,type) values(" + iMediaId + "," + iFolderId + ",'" + duplicateApostrof(sPath) + "','" + duplicateApostrof(sNaziv) + "','" + sYear + "','" + sGenre + "', 0 ,'N','" + sType + "')"; DataBase.executeNonQuery(sQuery); return(iMediaId); }