burncd Posted December 20, 2009 at 07:03 PM Report Share #301554 Posted December 20, 2009 at 07:03 PM Boas pessoal. Mais a realização de um projecto, mais uma dúvida. Alguém me sabe dizer como criar um ficheiro XML baseado no XSD já feito? Obrigado. Link to comment Share on other sites More sharing options...
bruno1234 Posted December 20, 2009 at 07:06 PM Report Share #301555 Posted December 20, 2009 at 07:06 PM Vê se ajuda: http://www.codeguru.com/forum/showthread.php?threadid=330043 Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos Link to comment Share on other sites More sharing options...
burncd Posted December 20, 2009 at 07:17 PM Author Report Share #301558 Posted December 20, 2009 at 07:17 PM Sim.. penso que com isto consiga fazer o que pretendo.... Obrigado pela ajuda e pela resposta rápida.... Mais alguma coisa entro em contacto convosco de novo... Ty Link to comment Share on other sites More sharing options...
burncd Posted December 20, 2009 at 11:10 PM Author Report Share #301593 Posted December 20, 2009 at 11:10 PM Já agora..... algum parser de CSV? O que estive a fazer não funciona em alguns dos casos. Link to comment Share on other sites More sharing options...
burncd Posted December 21, 2009 at 01:15 AM Author Report Share #301612 Posted December 21, 2009 at 01:15 AM ok... consegui resolver o problema e está a funcionar a 100% para os ficheiros... A solução que adoptei e que mais se adapta ao meu problema é a seguinte: private static string[] csvParser(FileInfo file) { string[] linha2 = null; try { StreamReader str = new StreamReader(file.FullName); char[] spliter = { ';' }; while (!str.EndOfStream) { string linha = str.ReadLine(); linha2 = linha.Split(spliter); } str.Close(); } catch (Exception e) { StreamWriter stw = new StreamWriter("log.txt"); stw.WriteLine(e.Message); stw.Close(); } return linha2; } Mas este tema de um parser de CSV se calha ficava melhor num outro tópico.... Deixo ao criterio do moderador desta parte do fórum. Cumpz BurnCd Link to comment Share on other sites More sharing options...
burncd Posted December 29, 2009 at 09:39 PM Author Report Share #303057 Posted December 29, 2009 at 09:39 PM Boas pessoal. Mais facil ainda conseguir o parse do CSV todo em muito menos linhas de código. string[] linha = File.ReadAllLines(path); char[] separador = {';'}; foreach(string aux in linha){ lista.Add(aux.Split(separador)); } Espero que ajude alguém. Cumpz Burncd Link to comment Share on other sites More sharing options...
bruno1234 Posted December 29, 2009 at 10:41 PM Report Share #303098 Posted December 29, 2009 at 10:41 PM o separador não precisas ser um char[ ], basta um char, ou então definires um constante com o valor ',' e passar essa constante. Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos Link to comment Share on other sites More sharing options...
burncd Posted December 29, 2009 at 11:20 PM Author Report Share #303111 Posted December 29, 2009 at 11:20 PM o separador não precisas ser um char[ ], basta um char, ou então definires um constante com o valor ',' e passar essa constante. Olha que não sei. Segundo a documentação necessita sempre de um vector: Dá uma olhadela aqui: http://msdn.microsoft.com/en-us/library/system.string.split.aspx Podes é fazer assim: string[] array = aux.Split(';'); Com as plicas '' não com aspas, "". Cumps Burncd Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now